944,167 Members | Top Members by Rank

Ad:
Oct 19th, 2005
0

create a query in access from vb6

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
mstangeh is offline Offline
3 posts
since Oct 2005
Nov 6th, 2005
0

Re: create a query in access from vb6

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
Reputation Points: 16
Solved Threads: 10
Junior Poster
Yomet is offline Offline
134 posts
since Nov 2005
Feb 24th, 2010
0
Re: create a query in access from vb6
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ben-Jammin is offline Offline
1 posts
since Feb 2010
Feb 24th, 2010
0
Re: create a query in access from vb6
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,
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. strSQL = "SELECT * FROM tablename WHERE fieldname = '" & Text1.Text & "'"



Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: MS-Access2003
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Decompile Delphi to VB6





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC