Hello everyone!
I have this code
string constring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DataBasePath + ";Persist Security Info=False;Jet OLEDB:Database Password="";
conn = new OleDbConnection(constring);
conn.Open()
string searchstring = "SELECT * FROM MyTable WHERE field2=@field2";
OleDbCommand cmdsearch = new OleDbCommand(searchstring, conn);
OleDbDataReader reader;
cmdsearch.Parameters.AddWithValue("@field2", dgrDoc[1, index].Value.ToString());
reader = cmdsearch.ExecuteReader();
How can I check if MyTable contains rows from dgrDoc, and if it does, to update in MyTable the row affected, else to insert new data in MyTable.
I use
if(reader.Read())
{
if(!reader.IsDBNul(1))
{
//update comand
}
else
{
//insert command
}
}
but it takes only rows contained in MyTable.
Can anyone help me? Thanks!