my accdb table structure is like below
(guys need urgent help please)
Field Datatype
Account-- Memo
AccountNumber--Number
Date--Date/Time
Description--Memo
Post_Ref--Memo
Debit--Number
Credit--Number
Balance--Number
code is :
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
string connectionString = null;
connectionString = ConfigurationManager.ConnectionStrings["AccessConnectionString"].ConnectionString;
con.ConnectionString = connectionString;
string cmd1 = "insert into Ledger([Account],[AccountNumber],[Date],[Description],[Post_Ref],[Debit],[Credit],[Balance])values(?,?,?,?,?,?,?,?)";
OleDbCommand cmd = new OleDbCommand(cmd1, con);
con.Open();
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Account",dataGridView1.Rows[e.RowIndex].Cells["Account"].Value.ToString());
cmd.Parameters.AddWithValue("@AccountNumber",int.TryParse(dataGridView1.Rows[e.RowIndex].Cells["AccountNumber"].Value));
cmd.Parameters.AddWithValue("@Date", DateTime.TryParse(dataGridView1.Rows[e.RowIndex].Cells["Date"].Value));
cmd.Parameters.AddWithValue("@Description", dataGridView1.Rows[e.RowIndex].Cells["Description"].Value.ToString());
cmd.Parameters.AddWithValue("@Post_Ref", dataGridView1.Rows[e.RowIndex].Cells["Post_Ref"].Value.ToString());
cmd.Parameters.AddWithValue("@Debit", Int32.TryParse(dataGridView1.Rows[e.RowIndex].Cells["Debit"].Value));
cmd.Parameters.AddWithValue("@Credit", Int32.TryParse(dataGridView1.Rows[e.RowIndex].Cells["Credit"].Value));
cmd.Parameters.AddWithValue("@Balance", Int32.TryParse(dataGridView1.Rows[e.RowIndex].Cells["Balance"].Value));
int n = cmd.ExecuteNonQuery();
con.Close();
Load_data();
}
ali tuncerPosted Mar 24, 2016, 6:06 AM
Atul RokadePosted Mar 24, 2016, 5:27 AM
ali tuncerPosted Mar 24, 2016, 12:23 AM
Atul RokadePosted Mar 22, 2016, 1:51 PM
Manas MohapatraPosted Mar 22, 2016, 1:37 PM
ali tuncerPosted Mar 22, 2016, 12:47 PM
Atul RokadePosted Mar 22, 2016, 12:11 PM
Krishna Rajput SinghPosted Mar 22, 2016, 6:48 AM
Atul RokadePosted Mar 22, 2016, 6:25 AM
Krishna Rajput SinghPosted Mar 21, 2016, 11:03 PM
Manas MohapatraPosted Mar 21, 2016, 1:44 PM