Update an Access database

Posted on 2006-03-22
Last Modified: 2010-04-23
I'm trying to update an Access database using this code. It won't work! Any ideas?


Dim strSQL As String
Dim MyConn As New Data.OleDb.OleDbConnection(gstr_ConnString)

strSQL = "Update tbl_aGlobalSettings Set FileName_DB, DefaultStation, zOriginDB_Versionz = " _
& "'" & Me.txtCurrentDBPath.Text & "'," _
& "'" & Me.txtDefaultStation.Text & "'," _
& "'" & Me.txtCurrentDBVersion.Text & "'" _
& " WHERE TracerID = 1"

Dim cmd As New OleDb.OleDbCommand(strSQL, MyConn)

cmd.ExecuteNonQuery() ' It Fails HERE.....

Question by:ADawn
    LVL 6

    Accepted Solution


    strSQL = "Update tbl_aGlobalSettings Set FileName_DB = '" & Me.txtCurrentDBPath.Text & "', " & _
                     "DefaultStation = '" & Me.txtDefaultStation.Text & "',"  & _
                     "zOriginDB_Versionz = '" & Me.txtCurrentDBVersion.Text & "' "  & _
                     " WHERE TracerID = 1"

    The strSQL should end up like

    Update tbl_aGlobalSettings Set FileName_DB = 'X', DefaultStation = 'Y', zOriginDB_Versionz = 'Z' WHERE TracerID = 1

    HTH :)
    LVL 1

    Expert Comment

    in the command window output the strSql and copy the line into Access as a query.  When you run it in access it will give you a better idea of the problem.


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now