Monday, 1 October 2012

Creating sql database connection in asp.net web application through C#

  • protected void Button1_Click(object sender, EventArgs e)
  • {
  • SqlConnection myConn = new SqlConnection();
  • myConn.ConnectionString = Connection string(See Below for this )COPY PASTE HERE“;
  • myConn.Open();
  • string strqry = Insert into students values (” + TextBox1.Text +
  • “,’” + TextBox2.Text + “‘,’” + TextBox3.Text + “‘)”;
  • SqlCommand myCom = new SqlCommand(strqry, myConn);
  • int numrow = myCom.ExecuteNonQuery();
  • myConn.Close();
  • }

  • No comments:

    Post a Comment