How to Insert a TextBox value in to Sql database using C#
coding?

Answer Posted / jegan

SqlConnection con = new SqlConnection();
con.ConnectionString = "connection string(path)";
try
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into emp_detail values(' " + tb1.Text + " ',' " + tb2.Text + " ',' " + tb3.Text + " ')", con);
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}

Is This Answer Correct ?    66 Yes 26 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Web API supports which protocol?

862


Why select Web API?

572


What are the namespaces used in asp.net mvc? : asp.net mvc

520


What is the state management in asp.net?

558


What is a 401 redirect?

522






What tags do you need to add within the asp:datagrid tags to bind columns manually? How?

526


Is viewstate enabled by default?

539


What is asp net application object?

549


What are merge modules?

564


What is a postback ispostback and autopostback in asp net?

483


how to retrieve property settings from xml .config file.

553


What is viewstategenerator?

708


How does asp.net work?

559


What is a multilingual website?

571


How do you deploy your asp.net application?

542