opening a database table 
Author Message
 opening a database table

Excuse me if this post is not in the correct group.

Could someone tell me how to open a database table using ADO command.
With a DAO command it might look something like this:

    Dim DB as DAO.Database
    Dim RS as DAO.Recordset

    Set DB = DAO.OpenDatabase (C:\Database")
    Set RS = DB.OpenRecordset (Name:="TableName")

I am familiar with the conversion to:

    Dim Conn as ADODB.Connection
    Dim RS as ADODB.Recordset

    Set Conn = New ADODB.Connection
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Database;"

It's the last command to open the table that has me stumped.
Thanks in advance.

Steve Pollack



Mon, 28 Nov 2005 16:19:18 GMT  
 opening a database table
There are a variety of ways here's one;

Dim rs AS ADODB.Recordset
Set rs = cn.Execute(strSQL)

Here's another:

Dim rs AS ADODB.Recordset
Set rs = New ADODB.Recordset
strSQL = "SELECT * FRM tblBlah;"
cn.Open 'open you configured connection
rs.Open strSQL, cn, [cursortype], [locktype] 'optional
arguments in []

BE AWARE: ADO works on the principle of "don't ask, won't
get".
So, in the above example(s), if you don't specify a fancy
cursor (to navigate your records) and/or specify the
record locking strategy then ADO will most likely give you
a set of forward only, read only records...

You can aslo use the command object:
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset

'set various properties of cmd object, including SQL,
then...
Set rs = cmd.Execute

I think if you use the command object you can specify a
table name rather than SQL - but I never have.


Quote:
>-----Original Message-----
>Excuse me if this post is not in the correct group.

>Could someone tell me how to open a database table using
ADO command.
>With a DAO command it might look something like this:

>    Dim DB as DAO.Database
>    Dim RS as DAO.Recordset

>    Set DB = DAO.OpenDatabase (C:\Database")
>    Set RS = DB.OpenRecordset (Name:="TableName")

>I am familiar with the conversion to:

>    Dim Conn as ADODB.Connection
>    Dim RS as ADODB.Recordset

>    Set Conn = New ADODB.Connection
>    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=C:\Database;"

- Show quoted text -

Quote:

>It's the last command to open the table that has me
stumped.
>Thanks in advance.

>Steve Pollack

>.



Mon, 28 Nov 2005 19:59:42 GMT  
 opening a database table
Hi Steve,

You would need to open recordset

Dim loRecordset as ADODB.Recordset

Set Conn = New ADODB.Connection
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Database;"

Set loRecordset=New ADODB.Recordset
loRecordset.Open "SELECT Field1, Field2, ..... FROM MyTable WHERE .....",
Conn

Also check next link with some examples of usind ADO

http://support.microsoft.com/default.aspx?scid=kb;en-us;172403

--
Val Mazur
Microsoft MVP


Quote:
> Excuse me if this post is not in the correct group.

> Could someone tell me how to open a database table using ADO command.
> With a DAO command it might look something like this:

>     Dim DB as DAO.Database
>     Dim RS as DAO.Recordset

>     Set DB = DAO.OpenDatabase (C:\Database")
>     Set RS = DB.OpenRecordset (Name:="TableName")

> I am familiar with the conversion to:

>     Dim Conn as ADODB.Connection
>     Dim RS as ADODB.Recordset

>     Set Conn = New ADODB.Connection
>     Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Database;"

> It's the last command to open the table that has me stumped.
> Thanks in advance.

> Steve Pollack



Mon, 28 Nov 2005 20:03:17 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Opening table in foreign database

2. How do I open a Table in an Access database from VB5

3. Opening database tables

4. Opening Database and Identifying Tables at Run-Time

5. Best way to open Databases/tables

6. open Access database and tables

7. Linking a dBase III table to an Access 2000 database - won't open

8. MS Access DB - Copy Table A from Database A to Table A Database B

9. Cannot open a table from a Access database file using VB5

10. Opening & Closing Databases/Tables

11. Linking tables vs. Opening tables directly

12. open Access table = locked Access table??

 

 
Powered by phpBB® Forum Software