- Back to Home »
- ASP.Net , C# , Umbraco »
Posted by : Jebastin
Saturday, 14 December 2013
Required Namespaces:
- using umbraco;
- using umbraco.BusinessLogic;
- using umbraco.DataLayer;
C# Code:
- public bool InsertData(string FirstName, string LastName, string Email, string Phone)
- {
- bool IsSuccessful = false;
- try
- {
- string InsertQuery = "INSERT INTO tblPerson(FirstName, LastName, Email, Phone, CreatedDate) values ";
- InsertQuery = InsertQuery + "(@FirstName, @LastName, @Email, @Phone, @CreatedDate)";
- Application.SqlHelper.ExecuteNonQuery(InsertQuery,
- Application.SqlHelper.CreateParameter("@FirstName", FirstName),
- Application.SqlHelper.CreateParameter("@LastName", LastName),
- Application.SqlHelper.CreateParameter("@Email", Email),
- Application.SqlHelper.CreateParameter("@Phone", Phone),
- Application.SqlHelper.CreateParameter("@CreatedDate", DateTime.Now));
- IsSuccessful = true;
- }
- catch
- {
- IsSuccessful = false;
- }
- return IsSuccessful;
- }