create a query in access from vb6

Reply

Join Date: Oct 2005
Posts: 3
Reputation: mstangeh is an unknown quantity at this point 
Solved Threads: 1
mstangeh mstangeh is offline Offline
Newbie Poster

create a query in access from vb6

 
0
  #1
Oct 19th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 134
Reputation: Yomet is an unknown quantity at this point 
Solved Threads: 10
Yomet Yomet is offline Offline
Junior Poster

Re: create a query in access from vb6

 
0
  #2
Nov 6th, 2005
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...

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Public Sub CreateQuery()
  2. 'NOTE: this code NEEDS to have a reference to DAO
  3. ' If you already have a reference to ADO be sure
  4. ' to prefix your variable declarations correctly
  5. ' since there are some objects that are the same
  6. ' and you will never know which will be opened
  7. ' unless you prefix them, i.e.
  8. ' Dim ADORecs As ADODB.Recordset
  9. ' Dim DAOResc As DAO.Recordset
  10. '
  11. Dim db As DAO.Database
  12. Dim MyQry As DAO.QueryDef
  13.  
  14. Set db = DBEngine.OpenDatabase("<path to your database")
  15. Set MyQry = db.CreateQueryDef("<Query name>", "<SQL statement>")
  16. db.Close
  17. End Sub

Have fun

Yomet
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC