Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating and Deleting Records from the DataGridView and database
    primarykey
    data
    text
    <p>i m new here, i want to update and delete the records from the datagridview as well as from database i have the following code for the update and delete..</p> <pre><code>int num = 0; foreach (DataGridViewRow row in this.dataGridView1.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { string ID = this.dataGridView1.Rows[row.Index].Cells["ID"].Value.ToString(); string CoCode = this.dataGridView1.Rows[row.Index].Cells["CoCode"].Value.ToString(); string CoName_mar = this.dataGridView1.Rows[row.Index].Cells["CoName_mar"].Value.ToString(); con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\mayur patil\\My Documents\\Dairy_db\\tblCompany_1.mdb"; con.Open(); OleDbCommand cmd = new OleDbCommand("UPDATE tblCompany_1 SET (CoCode=@CoCode,CoName_mar=@CoName_mar where ID=@ID)", con); cmd.Parameters.AddWithValue("CoCode", CoCode); cmd.Parameters.AddWithValue("CoName_mar", CoName_mar); cmd.Parameters.AddWithValue("ID", ID); cmd.ExecuteNonQuery(); con.Close(); num++; } } if (num &gt; 0) { MessageBox.Show("Record Updated !"); } this.Hide(); listOfCompany v = new listOfCompany(); v.ShowDialog(); </code></pre> <p>Add for delete records..</p> <pre><code>OleDbConnection con = new OleDbConnection(); con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\mayur patil\\My Documents\\Dairy_db\\tblCompany.mdb"; OleDbCommand cmd = new OleDbCommand ("DELETE FROM tblCompany WHERE (CoCode = i)"); con.Open(); cmd.ExecuteNonQuery(); con.Close(); </code></pre> <ol> <li><p>for the update query i m getting the error that"OleDbException was handled syntax error in UPDATE" at <code>cmd.ExecuteNonQuery();</code></p></li> <li><p>for the delete query i m getting the error "OleDbException was handled.. Could not find installable ISAM." at <code>con.Open();</code></p></li> </ol> <p>how should i overcome from this problem?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload