private void Form1_Load(object sender, EventArgs e) { com.Connection = con; }
private void button4_Click(object sender, EventArgs e) { SqlConnection con=new SqlConnection("Data Source=C:\asd;Initial Catalog=shivani; providerName=System.Data.SqlClient "); SqlCommand com = new SqlCommand(); if (txtname.Text != "" & txtage.Text != "") { con.Open(); com.CommandText = "insert into customer(customerName,customerCode) values ('" + txtname.Text + "','" + txtage.Text + "')"; com.ExecuteNonQuery(); con.Close(); MessageBox.Show("record inserted"); } else MessageBox.Show("data entry error"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)