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 the part of url?
What is event bubbling?
Differentiate the session object and application object?
Explain diff between dataset and datareader?
Will session work if cookies is disabled?
What are early binding and late binding.
Do session use cookies in asp net?
What are the various ways to send content from one page to another?
what are the events raised in asp.net page life cycle?in which stage view state can be loaded?
Which class is used to send an email message from an ASP.NET Web page?
How to create events for a control?
How can we access static variable?
Please briefly explain the usage of global.asax?
Explain the difference between the web config and machine config.
How do u deploy your asp.net application?