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
What is the current version of asp.net?
Can we handle the error and redirect to some pages using web.config?
Take a Large textbox allow to type any data. Task 1:display the count of vowels in a lable on key press event of the textbox Task 2:dispaly count of dates in a lable when dates in following foramats:dd/mm/yy , mm/dd/yy , yy/mm/dd. Task3:compare 2 dates and display both are same or not which dates are in dd/mm/yy and mm/dd/yy farmats.
What is cookies in asp net?
What is ispostback method in asp.net?
How can you display all validation messages in one control?
What is another word for redirect?
How ASP.NET page works?
What are the different types of validation controls in asp.net?
What is postback in asp net?
What is meant by web application?
Explain how dot net compiled code will become platform independent?
What is the difference between session and viewstate?
What does the .webpart file do?
What is asp.net mvc5? : Asp.Net MVC