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 tracing? Where is it used?
If I am developing an application that must accomodate multiple security levels though secure login and my asp.net web application is spanned across three web-servers (using round-robin load balancing). What would be the best approach to maintain login-in state for the users?
What is the difference between application state and caching?
Will the asp.net validators run in server side or client side?
Which property needs to be set for script manager control to extend the time before throwing time out expection if no response is received from the server?
What is use of Master Page in ASP.NET web pages?
What is the difference between session object and application object?
Explain how to prepare culture-specific formatting in .net.
Define data caching?
How could you modify xaml content from javascript?
What is localhost in asp.net?
What are the options in ASP.NET to maintain state?
How can we create Tree control in asp.net?
What is bson in web api?
How can you send an email message from an asp.net web page?