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

Answer Posted / jeevananth

try
{
SqlConnecion cn=new SqlConnection("Data
source=.;database=Studentdetail;uid=sa;pwd=sa");
SqlCommand cmd=new SqlCommand();
cn.Open();
string qry;
qry="insert into Table values('"+ TextBox1.Text +"','"+
TextBox2.Text +"')";
cmd=new(qry,cn);
cmd.cmd.ExecuteNonQuery();


cn.Close();
}
catch(Exception ex)
{
Responce.Write(ex.Message.ToString());
}

Is This Answer Correct ?    0 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does u call and execute a sp in .net?

538


What are directives in asp.net?

524


How can you implement the postback property of an asp.net control?

522


Name the tools or API for developing or testing web api?

525


Distinguish between Server-side and Client-side code with its functionality?

620






How could you modify xaml content from javascript?

505


Why mvc is faster than asp.net? : Asp.Net MVC

521


How ViewstateMac works?

2359


What is in a session cookie?

532


Describe how passport authentication works.

566


What is a ashx file?

548


What is the difference between ASP.NET Webforms and ASP.NET MVC?

602


Can more than one person use the same login?

568


What is considered a service provider?

511


Give an example of cookie abuse.

591