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
What are Master Pages in ASP.NET? or What is a Master Page?
What is the difference between c# and .net?
What is data cache in sql server?
Define view state.
How you will handle session when deploying application in more than a server?
What is a user session?
To display data in a Repeater control which template you provide?
Is asp.net and .net same?
Is global asax mandatory?
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
What is the viewstate in asp.net?
What is user control in asp.net?
What are type/key pairs in client script registration? Can there be 2 scripts with the same type/key pair name?
How you can stop the validation of ASP.NET controls from client side?
Can the dictionary object be created in client?s scope ?