Problem in adding record in an ODBC-connected Access database 
Author Message
 Problem in adding record in an ODBC-connected Access database

Hi all experts,

I have a problem in adding record into an Access database connected by
ODBC. My code is as that of end of this mail. Everything work OK but
error happen when the program reach the last line (i.e. ".Update"). The
error is "ODBC call failed" (3146).

From the help, it says it is because an ODBC connect is lost due to,
say, not logging-in to a network. However, the data source is an Access
database in my local hard drive and data retrieving is 100% correct.

I'm wondering what is wrong with these few lines of code.

Please help! Thank you!

William

Sub AddNewRecord()
    Dim dbsContent As Database
    Dim wrkODBC As Workspace
    Dim rstTmp As Recordset

    Set wrkODBC = CreateWorkspace("", "", "", dbUseODBC)
    Set dbsContent = wrkODBC.OpenDatabase("resource-db",
dbDriverNoPrompt,
False,"ODBC;DATABASE=resource-db;UID=;PWD=;DSN=resources")
    Set rstTmp = dbsContent.OpenRecordset("CUSTOMER", dbOpenDynaset,
dbExecDirect, dbOptimisticValue)

    With rstTmp
        .AddNew
        !CUST_ID = 1
        !CUST_NAME = "Peter"
        .Update <------------ Problem in this line
    End With
End Sub



Mon, 29 Apr 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Connect And Add New Records on a remote Database

2. Connecting to an Access 95 database via an ODBC driver in VB 5.0

3. HELP: Data Access Objects w/ ODBC connected to Oracle Database

4. HELP: Data Access Objects w/ ODBC connected to Oracle Database

5. Shared ODBC to connect to an Access DataBase

6. ODBC Connect string for MS Access 97 Database

7. Connecting to an Access 95 database via an ODBC driver in VB 5.0

8. Shared ODBC to connect to an Access DataBase

9. HELP--Problems Connecting to a Database (ODBC)

10. Problem connecting to Oracle Database using ODBC

11. HELP--Problems Connecting to a Database (ODBC)

12. Problems adding new records to ODBC source (dBASE III dbf's)

 

 
Powered by phpBB® Forum Software