hi,
I need to create or replace a permanent query in access (like a view in oracle, postgres...), but from vb6 using ADODB.
i know that i can create and alter tables using a ADODB connection object with something like this

dim obj as new adodb.connection
...
...
obj.execute "create table ......:"

but, how to create the views?????

thanks
mstangeh

Hi ,

Try this out, it worked well when I threw it together. But REMEMBER to read the note in the header... You have been warned... ;)

Public Sub CreateQuery()
'NOTE: this code NEEDS to have a reference to DAO
'      If you already have a reference to ADO be sure
'      to prefix your variable declarations correctly
'      since there are some objects that are the same
'      and you will never know which will be opened
'      unless you prefix them, i.e.
'      Dim ADORecs As ADODB.Recordset
'      Dim DAOResc As DAO.Recordset
'
    Dim db As DAO.Database
    Dim MyQry As DAO.QueryDef
    
    Set db = DBEngine.OpenDatabase("<path to your database")
    Set MyQry = db.CreateQueryDef("<Query name>", "<SQL statement>")
    db.Close
End Sub

Have fun

Yomet

Hi,

I know this is very late to the original post but I was just wondering if anybody knows how to create a query from the information inputted in textboxes/comboboxes in VB08?

I have a database system in Access but I need to be able to create queries through the information the user inputs in the VB form.

Any help would be great. This is for my A level school project.
Thanks :)

Well Ben, I have some advice for you...

1st, Don't necropost as you have because most everyone who has replied to this thread recieves an email. Instead, create your own thread and if necessary, copy the url of the old dead thread into your new thread posting.

2nd, Make sure you are posting in the right forum as VB.NET 2k8 is a whole different technology that VB6.0... (Which means you have posted in the wrong forum and need to post in the .NET forum in the future!!!)

3rd,

strSQL = "SELECT * FROM tablename WHERE fieldname = '" & Text1.Text & "'"

Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.