Use this code to save data into the Ms access database using c#.net
public void savedata()
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\SR050\\Documents\\VisitingCard.accdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("VisitingCard_Insert", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Names", textBox1.Text);
cmd.Parameters.AddWithValue("@Organization", textBox2.Text);
cmd.Parameters.AddWithValue("@Location", textBox3.Text);
cmd.Parameters.AddWithValue("@PhoneNo", textBox4.Text);
cmd.Parameters.AddWithValue("@EmailId", textBox5.Text);
int result = cmd.ExecuteNonQuery();
con.Close();
if (result > 0)
{
MessageBox.Show("Inserted Successfully");
}
}
public void savedata()
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\SR050\\Documents\\VisitingCard.accdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("VisitingCard_Insert", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Names", textBox1.Text);
cmd.Parameters.AddWithValue("@Organization", textBox2.Text);
cmd.Parameters.AddWithValue("@Location", textBox3.Text);
cmd.Parameters.AddWithValue("@PhoneNo", textBox4.Text);
cmd.Parameters.AddWithValue("@EmailId", textBox5.Text);
int result = cmd.ExecuteNonQuery();
con.Close();
if (result > 0)
{
MessageBox.Show("Inserted Successfully");
}
}
Comments
Post a Comment