How to Insert a TextBox value in to Sql database using C#
coding?
Answer Posted / digital
SqlCommand CmdSql = new SqlCommand("INSERT INTO
Customers(FirstName,Surname,Address,City,Postcode,PhoneNumber)
Values
(@FirstName,@Surname,@Address,@City,@Postcode,@PhoneNumber)", conn);
conn.Open();
CmdSql.Parameters.AddWithValue("@FirstName", FirstName);
CmdSql.Parameters.AddWithValue("@Surname", Surname);
CmdSql.Parameters.AddWithValue("@Address", Address);
CmdSql.Parameters.AddWithValue("@City", City);
CmdSql.Parameters.AddWithValue("@Postcode", Postcode);
CmdSql.Parameters.AddWithValue("@PhoneNumber",
PhoneNumber);
CmdSql.ExecuteNonQuery();
conn.Close();
//all @values are names of the variables the text value is
stored as (you could also enter txtFirstName.Text etc.)
//conn = connection name (which should be declared before
the page_load
| Is This Answer Correct ? | 113 Yes | 35 No |
Post New Answer View All Answers
What is role-based security in asp.net?
Error : The operation couldn’t be performed because ole db provider sqlncli10 for linked server was unable to begin a distributed transaction.00000110 oledb provider for linked server returned message the partner transaction manager has disabled its support for remote/network transactions. I can able to execute the stored procedure in sql server but when i run the web page getting error like above. I did all the configuration. what is the solution?
What is query string in asp.net?
Please brief not about xsd,xslt & xml?
if i wanna deploy my asp.net project to the production server and situation is that i m still not compiled my project i have as-is on my development side now on production server we dont have a visual studio now what kind of settings i need to be to do in webconfig /machine.config file to deploy my project and in iis too....
What is rending process in ASP.NET?
How ASP and ASP.NET page works? Explain about asp.net page life cycle?
What is the web.config file in asp?
Which protocol is used to call a web service?
What is the namespace to create thread in .net?
Difference between DataGid and Girdview? Difference b/w .Net 2.0, 3.0 and 3.5 ? Diff b/w dispose & Finialize Methods?
In Data grid the question is below quantity price total these are 3 fields available in data grid if you enter quantity the total has to update automatically.Price field is already filled completely
How do you use viewstate?
Is it possible to create web application with both webforms and mvc?
What is in a session cookie?