Data Commands OleDb
-
I need to allow an administrator to change login passwords for my application but am having problems with the syntax for the UPDATE statement. Specifically, I want to use Data Commands rather than working through a data set to make the updates because I will only need to do two operations with the MS Access database-verifying the old password/user id combo and updating the password to a new one. It seems to me that the UPDATE statement requires paramaters, but I am unsure of the syntax. Any help would be appreciated. Thanks.
-
I need to allow an administrator to change login passwords for my application but am having problems with the syntax for the UPDATE statement. Specifically, I want to use Data Commands rather than working through a data set to make the updates because I will only need to do two operations with the MS Access database-verifying the old password/user id combo and updating the password to a new one. It seems to me that the UPDATE statement requires paramaters, but I am unsure of the syntax. Any help would be appreciated. Thanks.
The syntax for the SQL command you will need is easy:
UPDATE [table] SET [field]=[value],[field]=value,.. WHERE [filterexpression]
Replace the [...] for the actual names and values. For the rest you need a simple piece of code like this:OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=mydb.mdb");
OleDbCommand cmd = new OleDbCommand(query,connection);try {
connection.Open();
cmd.ExecuteNonQuery();
}
catch {
//Whatever needs to be catched
}
finally {
connection.Close();
}Good luck. WM.
What about weapons of mass-construction? -
I need to allow an administrator to change login passwords for my application but am having problems with the syntax for the UPDATE statement. Specifically, I want to use Data Commands rather than working through a data set to make the updates because I will only need to do two operations with the MS Access database-verifying the old password/user id combo and updating the password to a new one. It seems to me that the UPDATE statement requires paramaters, but I am unsure of the syntax. Any help would be appreciated. Thanks.
If you were working thru a dataset you would not have to know any SQL statements after populating the dataset. Using the dataset is simple 1> create and fill the dataset with dataAdapter. 2> create new SQL command builder associated with dataAdapter 3> get new row from DataTable edit row(record) - (user/password) 4> simply update the database thru the adapter Besides from initially populating the dataset no SQL involved