Wanting2LearnMan
asked on
Check if value exists in Access Database using c#
I wish to enter data into my access database table like so:
private OleDbConnection mycon;
string sDBPath = Application.StartupPath;
string sConnection = string.Format("Provider=Mi crosoft.Je t.OLEDB.4. 0;Data Source={0}\\MyAccessDB.mdb ;Persist Security Info=False", sDBPath);
mycon = new OleDbConnection(sConnectio n);
OleDbCommand cmd = mycon.CreateCommand();
cmd.CommandText = "insert into MyTable values('" + sID + "','" + sData1+ "','" + sData2+ "','" + sData3+ "','" + sData4+ "');";
cmd.ExecuteNonQuery();
mycon.Close();
My question is how do I check if an entry already exists in the database row. e.g. the first variable sID above?
Thanks
private OleDbConnection mycon;
string sDBPath = Application.StartupPath;
string sConnection = string.Format("Provider=Mi
mycon = new OleDbConnection(sConnectio
OleDbCommand cmd = mycon.CreateCommand();
cmd.CommandText = "insert into MyTable values('" + sID + "','" + sData1+ "','" + sData2+ "','" + sData3+ "','" + sData4+ "');";
cmd.ExecuteNonQuery();
mycon.Close();
My question is how do I check if an entry already exists in the database row. e.g. the first variable sID above?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.