Creating an Access Query Programmatically using ADO


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Creating an Access Query Programmatically using ADO

  1. #1
    Dee Lewis Guest

    Creating an Access Query Programmatically using ADO


    Hi Dan,

    I have several of your books...and let me say "thanks...they are the best".

    Now, I would like to know how I might be able to create an Access2000 querydef
    using the ADO 2.1 library.

    It seems that one might have to use ADOD.Command objects to pass a name,
    and the sql text to actually store the query permanently in the Access database.
    Only, nothing I have tried seems to get the job done.

    I try:

    Sub SaveQry(strName As String, strSQL As String)
    On Error GoTo ErrH

    Set objCmd = New ADODB.Command
    objCmd.CommandText = strSQL
    Set objCat.Procedures(strName).Command = objCmd <---- Error Here

    Set objCmd = Nothing
    Exit Sub
    ErrH:
    MsgBox Err.Description
    Exit Sub

    End Sub


    ..the result is an error on the Set objCat.Procedures line.

    Help!!! Please.

    Thanks in advance, and kkep up the great work.

    Dee Lewis

    Share on Google+

  2. #2
    Dan Appleman Guest

    Re: Creating an Access Query Programmatically using ADO

    Dee:

    Sorry, I'm not a database guy. I've always created my queries using Access and used
    them from ADO.
    I would suggest exploring MSDN - there must be an example of that somewhere.

    Dan


    Dee Lewis wrote:

    > Hi Dan,
    >
    > I have several of your books...and let me say "thanks...they are the best".
    >
    > Now, I would like to know how I might be able to create an Access2000 querydef
    > using the ADO 2.1 library.
    >
    > It seems that one might have to use ADOD.Command objects to pass a name,
    > and the sql text to actually store the query permanently in the Access database.
    > Only, nothing I have tried seems to get the job done.
    >
    > I try:
    >
    > Sub SaveQry(strName As String, strSQL As String)
    > On Error GoTo ErrH
    >
    > Set objCmd = New ADODB.Command
    > objCmd.CommandText = strSQL
    > Set objCat.Procedures(strName).Command = objCmd <---- Error Here
    >
    > Set objCmd = Nothing
    > Exit Sub
    > ErrH:
    > MsgBox Err.Description
    > Exit Sub
    >
    > End Sub
    >
    > .the result is an error on the Set objCat.Procedures line.
    >
    > Help!!! Please.
    >
    > Thanks in advance, and kkep up the great work.
    >
    > Dee Lewis


    Share on Google+

Similar Threads

  1. Replies: 1
    Last Post: 10-16-2002, 01:15 PM
  2. SV: Access DB and ADO
    By Tord Lindberg in forum VB Classic
    Replies: 0
    Last Post: 03-26-2001, 04:08 PM
  3. ADO Foxpro Free Table to Access Table
    By Paul Webster in forum VB Classic
    Replies: 0
    Last Post: 12-09-2000, 10:02 AM
  4. But..Re: Pass value to ADO query
    By Tom Wilson in forum VB Classic
    Replies: 0
    Last Post: 10-06-2000, 04:06 PM
  5. Sending a query to ADO with then character 39 :'
    By Jean-Claude LEPOT in forum authorevents.vaughn
    Replies: 1
    Last Post: 05-31-2000, 01:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center