Hello All,
I setup ODBC DSN name to connect to MS Access DB.
Public Function OpenDB() As String
Dim buffer As String
buffer = "DSN=name;UID=;PWD="
OpenDB = buffer
End Function
Private Sub cmdStart_Click()
Dim GetDBConn As String
Dim sql As String
GetDBConn = OpenDB()
sql = "select INV from PO"
rst.Open sql, cnn, adOpenDynamic, adLockOptimistic
With rst
If Not .EOF And Not .EOF Then
.MoveNext
MsgBox (rst.Fields(0))
End If
End With
cnn.Close 'close database
End Sub
I got a message error on line:
rst.open sql, cnn, addOpenDynamic,........
the exact error is "The Connection cannot be used to perform this operation. It is either closed or invalid in this context"
Do you see anything wrong with my code?
thanks,
myasin
I setup ODBC DSN name to connect to MS Access DB.
Public Function OpenDB() As String
Dim buffer As String
buffer = "DSN=name;UID=;PWD="
OpenDB = buffer
End Function
Private Sub cmdStart_Click()
Dim GetDBConn As String
Dim sql As String
GetDBConn = OpenDB()
sql = "select INV from PO"
rst.Open sql, cnn, adOpenDynamic, adLockOptimistic
With rst
If Not .EOF And Not .EOF Then
.MoveNext
MsgBox (rst.Fields(0))
End If
End With
cnn.Close 'close database
End Sub
I got a message error on line:
rst.open sql, cnn, addOpenDynamic,........
the exact error is "The Connection cannot be used to perform this operation. It is either closed or invalid in this context"
Do you see anything wrong with my code?
thanks,
myasin