By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Running access query in Vb.net

P: 1
Hello,
I have an access database and have a simple query in which i have 1 parameter.
I want to run this query in vb.net and display the results in a datagrid or anything but in vb.net.
I'm able to run the query but wht should i do to display the results of the query.
the code i m using now is:

Dim accApp As Object
accApp = GetObject("c:\mydb.mdb")

'this will run the query in the database
accApp.docmd.OpenQuery("myQuery")
accApp.Run("myQuery")
Aug 19 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 112
Right now you are attempting to automate Access, which doesn't get you where you want to go because you're trying to put the application logic in vb.net. In other words what you want access to is not the Access objects, but the Data objects. To do this you will need to read up on ADO.net, the data connection API provided by the .net framework. In your case you will want to use OleDb. This gives you the ability to pull data from a table (or query) and use it in various ways, such as place it in a Dataset which can be used as the DataBinding for a Datagrid or other objects. This is actually quite a large topic and I think that it would probably be best to read up on this component of the .Net framework. Most beginning VB.net books that I have read explain the use of Ado.net using Access as the sample data store. I would recommend either looking in one of those, or searching online for ADO.Net because that is what you will want to understand to utilize the data from your Access database.
Aug 20 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.