Create a stored query using oledb

Posted on 2006-04-19
Last Modified: 2008-02-26
I used the following syntax in vb.6
How do I perform this task using oledb in 2005

private sub createQuery
Dim qdfNew     As QueryDef
 Dim SQL        As String
 On Error Resume Next

 SQL = "select * from QrySubRegData UNION ALL Select * from QrySubBeerData;"
 With db
   .QueryDefs.Delete "QryUnionResetBase"
   Set qdfNew = .CreateQueryDef("QryUnionResetBase", SQL)
 End With
end sub
Question by:visualbasic
    1 Comment
    LVL 96

    Accepted Solution

    You cannot do that with ADO.NET, but you can always add a reference to DAO, and do it the old way:


      db.CreateQueryDef("", "SELECT * FROM QrySubRegData UNION ALL SELECT * from QrySubBeerData;"


    End Try


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    This video discusses moving either the default database or any database to a new volume.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now