Updating A SQL server table through DAO and ODBC In Access 2000 
Author Message
 Updating A SQL server table through DAO and ODBC In Access 2000

You need to create a CONNECTION object from an ODBC workspace - then you can
open recordsets and/or execute SQL against it.  Check out the
createworkspace method in the help file...

PKM

I have a Database of clients in a SQL Server 7 database that I'm cleaning up
the cities and addresses (left over from a cruddy Mac database). What is the
problem with my code to so I can have an updateable recordset?  I know that
pass through queries are not updateable.  I can run stored procedures and
pass through queries but can't pull out an updatable query like I can with
an attached ODBC or MDB table.
Set db = CurrentDb
strSQL = "Select ClientRecID, Address, City, State From Clients"
Set qryClient = db.CreateQueryDef("")
qryClient.Connect = strConnect
qryClient.SQL = strSQL
Set rstClient = qryClient.OpenRecordset
rstClient.Edit  (this is the point that it fails)
Any help would be greatly appreciated.
Thanks,
Steve House



Sat, 17 Aug 2002 03:00:00 GMT  
 Updating A SQL server table through DAO and ODBC In Access 2000
Thanks, but that is why I'm asking, an attached table is way too slow.  Been
there, done that.
Quote:

> for MDB you can link SQL server table "Clients" to mdb and open it like
> db.OpenRecordset("Select ClientRecID, Address, City, State From
> Clients",dbopendynaset)

> not so efficient, but updatable



> I have a Database of clients in a SQL Server 7 database that I'm cleaning up
> the cities and addresses (left over from a cruddy Mac database). What is the
> problem with my code to so I can have an updateable recordset?  I know that
> pass through queries are not updateable.  I can run stored procedures and
> pass through queries but can't pull out an updatable query like I can with
> an attached ODBC or MDB table.
> Set db = CurrentDb
> strSQL = "Select ClientRecID, Address, City, State From Clients"
> Set qryClient = db.CreateQueryDef("")
> qryClient.Connect = strConnect
> qryClient.SQL = strSQL
> Set rstClient = qryClient.OpenRecordset
> rstClient.Edit  (this is the point that it fails)
> Any help would be greatly appreciated.
> Thanks,
> Steve House




Sat, 17 Aug 2002 03:00:00 GMT  
 Updating A SQL server table through DAO and ODBC In Access 2000
for MDB you can link SQL server table "Clients" to mdb and open it like
db.OpenRecordset("Select ClientRecID, Address, City, State From
Clients",dbopendynaset)

not so efficient, but updatable


I have a Database of clients in a SQL Server 7 database that I'm cleaning up
the cities and addresses (left over from a cruddy Mac database). What is the
problem with my code to so I can have an updateable recordset?  I know that
pass through queries are not updateable.  I can run stored procedures and
pass through queries but can't pull out an updatable query like I can with
an attached ODBC or MDB table.
Set db = CurrentDb
strSQL = "Select ClientRecID, Address, City, State From Clients"
Set qryClient = db.CreateQueryDef("")
qryClient.Connect = strConnect
qryClient.SQL = strSQL
Set rstClient = qryClient.OpenRecordset
rstClient.Edit  (this is the point that it fails)
Any help would be greatly appreciated.
Thanks,
Steve House



Sun, 18 Aug 2002 03:00:00 GMT  
 Updating A SQL server table through DAO and ODBC In Access 2000

You will have to use an ADO recordset inside your Acc97 database.  You will set a reference to the ADO object.  The details on making the connection read/write can be found in the ADO help files since I am not that proficient with ADO yet..(you have to make it a server side cursor)

Here is the rub though, since the references are scanned by the VBA engine in alphabetical order AND both ADO and DAO have a database and recordset object, once you reference ADO inside your project, VBA will think all your RS are of type ADO -- to fix this always explicity declare your objects:
DIM db AS DAO.Database   instead of DIM db as Database
DIM rs AS DAO.Recordset  instead of  DIM rs as Recordset

for the ADO objects you use:
DIM rs as ADO.recordset

enjoy,
Patrick McCarthy

PS - you could use CREATEOBJECT() instead of referencing the ADO library in Access -- it saves time searching for all your objects and explicitly delcaring the library.  A note:  Start to explicitly declare ALL your objects to avoid the problem in the future....


  Thanks, but  I'm already doing the equivalent in my code.  strConnect, declared as a global variable, is the connection string that I use for the SQL Server database throughout my code (It works just fine to connect).  As I said, " I can run stored procedures and pass through queries but can't pull out an updateable query like I can with an attached ODBC or MDB table."  How do you make an updateable query through an ODBC connection with DAO, by not attaching the table?

    You need to create a CONNECTION object from an ODBC workspace - then you can
    open recordsets and/or execute SQL against it.  Check out the
    createworkspace method in the help file...
    PKM


    I have a Database of clients in a SQL Server 7 database that I'm cleaning up
    the cities and addresses (left over from a cruddy Mac database). What is the
    problem with my code to so I can have an updateable recordset?  I know that
    pass through queries are not updateable.  I can run stored procedures and
    pass through queries but can't pull out an updatable query like I can with
    an attached ODBC or MDB table.
    Set db = CurrentDb
    strSQL = "Select ClientRecID, Address, City, State From Clients"
    Set qryClient = db.CreateQueryDef("")
    qryClient.Connect = strConnect
    qryClient.SQL = strSQL
    Set rstClient = qryClient.OpenRecordset
    rstClient.Edit  (this is the point that it fails)
    Any help would be greatly appreciated.
    Thanks,
    Steve House



Mon, 19 Aug 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Access 2000 VBA/SQL - cannot create pseudo-index on linked SQL Server table

2. HELP!!..accessing access 2000 with linked SQL Server tables

3. DNS less Access Linked tables to SQL Server 2000

4. doing updating from grid to sql server with stored procedure sql 2000

5. Executing MS SQL Server 2000 stored procs via MS Access 2000

6. Acc2000: Access tables attached to SQL-Server won't update

7. Need Connection string for VB6 DAO DSN-LESS Connections to SQL Server 2000

8. Need Connection string for VB6 DAO DSN-LESS Connections to SQL Server 2000

9. ~ODBC In VB For SQL Server 2000

10. VB6 application using SQL Server 2000 migrating db to SQL Server 2

11. Can't view SQL Server 2000 tables in VB6 Data Environment

12. Can't view SQL Server 2000 tables in VB6 Data Environment

 

 
Powered by phpBB® Forum Software