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

Please brief not about xsd,xslt & xml?

756


How can you dynamically add user controls to a page?

705


What are the new web part controls in asp.net 2.0 ?

711


Which type if caching will be used if we want to cache the portion of a page instead of whole page?

692


What are the authentication types in asp.net?

788


Difference between Response.redirect vs server.transfer?

869


What is ispostback property?

689


Is asp.net outdated?

725


Explain transparent caching with aop?

709


Explain the difference between sql invalidation and sql notification.

747


What are the different properties of server control that exists?

787


What does clearing cache?

713


What is marshalling ? Is it a part of asp.net ?

829


Define secured sockets layer.

706


What is the difference between web.config and machine.config in ASP.NET?

832