How to Insert a TextBox value in to Sql database using C#
coding?
Answer Posted / anand
SqlConnection con = new SqlConnection();
con.ConnectionString = "data source=anand\\sqlexpress.
initial catalog=Database1;integrated security=sspi;";
SqlCommand myCommand = new SqlCommand();
myCommand.CommandText = "Insert into
usr(firstname,lastname,dob,phno,email,Address,state,bgroup)
Values('" + firstname.Text + "','" + lastname.Text + "'," +
dob.Text + "," + phno.Text + ",'" + email.Text + "','" +
Address.Text + "','" + state.Text + "','" + bgroup.Text + "')";
myCommand.Connection = con;
con.Open();
myCommand.ExecuteNonQuery();
con.Close();
| Is This Answer Correct ? | 5 Yes | 4 No |
Post New Answer View All Answers
Explain the difference between AutoPostBack and IspostBack in ASP.NET?
Difference between application events and session events
What is state management technique?
To display data in a Repeater control which template you provide?
How do we assign page-specific attributes?
What is the life-span of the items in the viewstate?
Which is better session or viewstate?
What are the advantages of Web API?
What is the difference between session object and application object?
Define globalization and localization.
Define xmlreader class.
How you can access the properties and controls of master pages from content pages?
What is meant by web application?
How many validators do ASP.NET have?
Define a web service in .net?