I'm not sure what it is that i'm doing incorrectly here- in the debugger the changes made to the filename are made correctly to the dataset that i'm pulling from for my update command, but when i check the database afterwards no changes have been made... so i'm a bit confused...
using (System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=J:\\Physics.mdb"))
{
using (OleDbDataAdapter dbAdapter = new OleDbDataAdapter("select thesisID, filename FROM Theses", con))
{
DataSet ds = new DataSet();
con.Open();
dbAdapter.Fill(ds);
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
ds.Tables[0].Rows[j]["filename"] = ds.Tables[0].Rows[j]["filename"].ToString().Replace(',', '_');
string newFileName = ds.Tables[0].Rows[j]["filename"].ToString();
int ID = Convert.ToInt32(ds.Tables[0].Rows[j]["thesisID"].ToString());
using (OleDbCommand updateCommand = con.CreateCommand())
{
updateCommand.CommandText = "update theses set filename = @newFileName where thesisID = @ID";
updateCommand.Parameters.AddWithValue("@ID", ID);
updateCommand.Parameters.AddWithValue("@newFileName", newFileName);
updateCommand.ExecuteNonQuery();
}
}
con.Close();
}
}