Update an Access database

I'm trying to update an Access database using this code. It won't work! Any ideas?

VS2003

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)

MyConn.Open()
cmd.ExecuteNonQuery() ' It Fails HERE.....
MyConn.Close()


ADawn
ADawnAsked:
Who is Participating?
 
cubixSoftwareCommented:
Try

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 :)
0
 
sbarrow1Commented:
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.

Stephen
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.