Sunday, August 19, 2012

STORE VALUES INTO YOUR DB.



using System.Data.SqlClient;


 private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("server=localhost;user id=sa;password=123;database=sixpm_csharp");
            con.Open();
            SqlCommand com = new SqlCommand("insert into empinfo values(" + textBox1.Text + ",'" +      textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "'," + textBox5.Text + ")", con);
            com.ExecuteNonQuery();
            MessageBox.Show("Record saved");
            com.Dispose();
            con.Close();
        }

No comments:

Post a Comment