Writing update back to MSAccess table?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi All,

I'm building a Windows Form application that will use a Microsoft
Access mdb file as a data store.

I have a section of code that is executed when the main form is closed
that _should_ update a setting value in a table in my mdb file. The
code executes without any error, but the value in the table appears
unchanged when I open up the table in the mdb file. I call this
function in the FormClosed event of the app's main form.

Code for the function is below:

private void fnSetRewardRemain()
{
using (OleDbConnection conn = new
OleDbConnection(ConnString)){
string thisval = "20";
string CommandString = "UPDATE tblSettings SET
settingval = '" + thisval + "' WHERE setting = 'remainreward'";
OleDbCommand remcom = new OleDbCommand(CommandString,
conn);
remcom.Connection.Open();
remcom.ExecuteNonQuery();
remcom.Dispose();
conn.Close();
}
}

In the example I'm attempting to write the 'hard coded' value of '20'
back to the table. If I write the value of CommandString out to the
console, and manually run it as a query in the mdb file itself, it
works fine. I'm assuming that I'm supposed to do something to 'flush'
the update back to the database, but I'm not sure what. If it helps,
the mdb was created in Acc2003 and is the 2002-2003 compatible file
structure.

Can anyone help me figure out how to get the update to write back to
the actual database?

Many thanks in advance,

pt

.



Relevant Pages

  • Re: OutputTo RTF Problem - Access 2007
    ... DoCmd.OutputTo acOutputReport, "rpt-TOC Summary", acFormatRTF, ... Microsoft Access MVP ... When I run this code in an mdb file, it executes with no problems. ...
    (comp.databases.ms-access)
  • Re: OutputTo RTF Problem - Access 2007
    ... Have you had a look at Stephen Lebans ReportSpecs.mde? ... It might be more than you need, but it works well in my apps. ... When I run this code in an mdb file, it executes with no problems. ...
    (comp.databases.ms-access)
  • OutputTo RTF Problem - Access 2007
    ... When I run this code in an mdb file, it executes with no problems. ... When I execute the same function when compiled in an mde file, ... Error Number "438" (Object doesn't support this property or method). ...
    (comp.databases.ms-access)
  • Re: QRe: Legacy Access 2 VB 4 app, Word 11 merge on XP Pro SP2 client
    ... selecting "blank database" or some such. ... possible to set a simple password on a whole mdb file, ... case, make sure you have a backup of the .mdw file, then launch Access ... >I could not get the app to accept the changes to Notepad within the ...
    (microsoft.public.access.conversion)
  • Re: Basic security questions
    ... Your ASP page would "connect" to the file on the Unix box via ADO or ADO.NET ... Password protected databases are different from database protected by ULS ... ULS protected databases require the use of the .mdw workgroup file ... >> If you double-click an mdb file, the sequence of actions is as follows. ...
    (microsoft.public.access.security)