Am using MsAccess as my database and VB6. I have some queries that I use with my database. Is it possible to use MsAccess queries in VB6? If yes, how do I code in order to use the queries?
Printable View
Am using MsAccess as my database and VB6. I have some queries that I use with my database. Is it possible to use MsAccess queries in VB6? If yes, how do I code in order to use the queries?
You can use ADO and its Command Object to execute an Access query or you can use the Access Object Model or DAO, etc. There is a good ADO db tutorial in the Database forum's sticky threads at the top of its forum.
Sorry, but I have checked the database threads and I have not seen where they explain how to use an MSAccess query. please help
Do you have knowledge of using ADO? If not then I suggest going over the tutorial located here - http://vbforums.com/showthread.php?t=349994
Then its just a matter of setting up a Command object passing the query name but it will return a forward only, read only recordset if you need to perform any updates on it then you will need to execute an action statment additionally.
In fact it's a great tool. You can build a query in Access very easily in design view, then go to SQL, copy the SQL statement and (once you've learned ADO in VB6) paste it into the VB IDE as a string. Add text box or combo box values for your Where clause and you can have a pretty complex VB query done in a few minutes.Quote:
Originally Posted by osemollie
The opposite is also a great tool. Set a breakpoint in VB to just after your SQL string is created, debug.print it, copy it and paste it into Access. Access gives you a better indication of where an error is. ("Syntax Error" in VB isn't all that helpful if you have a huge SQL statement.)