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
Fetch one page value to another page without using state-managment ?
What do you mean by serialize?
What is owin authentication?
Explain login control and form authentication.
Why would a company use an application service provider?
What is s2s tracking?
How can you handle unmanaged code exceptions in asp.net?
Is asp.net and .net the same?
Does asp.net still recognize the global.asa file?
Why asp.net mvc is better than asp.net? : Asp.Net MVC
Where viewstate value is stored in asp.net?
How to use push notification?
What is sta?
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 the difference between page-level caching and fragment caching?