Sinoyolo Zatelela
How to code a button save, so to save to the database?
By Sinoyolo Zatelela in C# on Jun 27 2011
  • nadeem janu
    Jul, 2011 2

    firstly you add the namspace....
    using System.Data.SqlClient;


    private void button1_Click(object sender, EventArgs e)
            {
                SqlConnection con = new SqlConnection();
                con.ConnectionString = "Data Source=SR; Initial catalog=nadeem;  user id=sa; password=<123>";
                con.Open();
                SqlCommand cmd = new SqlCommand("insert into login values ('" + textBox1.Text + "',' " + textBox2.Text + " ')", con);
                SqlDataReader dr = cmd.ExecuteReader();
                MessageBox.Show("save your data");
                con.Close();
            }


    Regards-Nadeem.


    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS