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

Explain what is viewstate?

555


Why is the standalone environment only useful during the development process?

1349


What is the difference between cache and cookies?

529


Can we set master page as a start page?

555


How do I create a web form?

540






How to send a DataReader as a parameter to a remote client ?

2733


can any one find and tell the difference between dot net and php which one is best ? which one we get more salary? which one is stable and which one is best for freshers and also better in future and carrer ? which one we wil get more salary sir ? please send ur valuable suggestions to kiranpulsar2007@gmail.com

1491


What is the usie of activex control in .net?

566


Explain how cookies work.

604


What is session in web technology?

533


Differentiate between a hyperlink control and a linkbutton control.

569


Explain different types of validators in asp.net?

541


What are the advantages of Web API?

644


What is parse in asp.net?

563


What is the difference between page-level caching and fragment caching?

543