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

What are sessions in asp net?

508


How ASP.NET page works?

668


How many validators do ASP.NET have?

594


How will you do Redo and Undo in a TextControl?

656


Which methods validate all the controls on a page?

531






Explain login control and form authentication.

547


What does postback mean?

522


Is there any limit for query string? Means what is the maximum size?

474


What is the advantage of mvc over asp.net? : Asp.Net MVC

490


How you can manage the state of application at the server side in ASP.NET?

560


Can you explain one critical mapping? Performance issue which one is better? Whether connected lookup tranformation or unconnected one?

794


What is cache in asp net?

518


Where viewstate value is stored in asp.net?

581


What are the advantages of the code-behind feature?

527


How can you ensure a permanent cookie?

544