Tuesday, October 29, 2013

new sql connnection

 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\users\codem\documents\visual studio 2012\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf;Integrated Security=True");
            SqlCommand cmd;
            con.Open();
            cmd=new SqlCommand("insert into kkk values('"+textBox1.Text+"','"+textBox2.Text+"')",con);
            cmd.ExecuteNonQuery();
            MessageBox.Show("inserted");
            con.Close();

No comments:

Post a Comment