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 viewstate? What does the "enableviewstate” property do? Whay would I want it on or off?
What is asp.net and its advantages?
Can you explain the basic use of dataview?
How does exception management works in ASP.NET?
What is the file extension of web service?
What is asp according to you?
What is windows active directory authentication?
Define static function?
What’s the use of “GLOBAL.ASAX” file?
What is preprocessor in .net and type, where it use?
What is form submit?
Explain how dot net compiled code will become platform independent?
Define resource files.
Explain why it is useful to use mvc instead of webforms? : asp.net mvc
What are directives in asp.net?