473,385 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

running Access Queries

Hi,

Through Visual Basic code can I run an Microsoft Access query? If so, how?

Thanks in advance
bbdobuddy
Nov 21 '05 #1
3 983
Is it a pre-existing query in Access, or are you wanting to pass an SQL
query to an Access table?

If it's the latter, you make an OLEDB connection to the Access database,
create an OLE command reference, and set the command text to your SQL query,
then execute the command.

"bbdobuddy" <bb*******@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Hi,

Through Visual Basic code can I run an Microsoft Access query? If so,
how?

Thanks in advance
bbdobuddy

Nov 21 '05 #2
It is a pre-exitsting query in Access.

"Jason" wrote:
Is it a pre-existing query in Access, or are you wanting to pass an SQL
query to an Access table?

If it's the latter, you make an OLEDB connection to the Access database,
create an OLE command reference, and set the command text to your SQL query,
then execute the command.

"bbdobuddy" <bb*******@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
Hi,

Through Visual Basic code can I run an Microsoft Access query? If so,
how?

Thanks in advance
bbdobuddy


Nov 21 '05 #3
On Thu, 20 Jan 2005 06:11:02 -0800, bbdobuddy <bb*******@discussions.microsoft.com> wrote:

¤ Hi,
¤
¤ Through Visual Basic code can I run an Microsoft Access query? If so, how?
¤

The following executes a SELECT query and populates a DataTable and DataGrid:

Dim AccessConn As System.Data.OleDb.OleDbConnection

AccessConn = New System.Data.OleDb.OleDbConnection("Provider=Micros oft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\db1.mdb")

AccessConn.Open()

Dim AccessCommand As New System.Data.OleDb.OleDbCommand("qryTable1", AccessConn)
AccessCommand.CommandType = CommandType.StoredProcedure

Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter

With da
.SelectCommand = AccessCommand
End With

Dim ds As New DataSet("QueryTables")
da.Fill(ds, "Table1")

DataGrid1.SetDataBinding(ds, "Table1")

AccessConn.Close()
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MSW | last post by:
I am trying to give the user some indication of some progress of a query since it takes about 5 hours to run. Is there any way to extract the progress of a query WHILE it is running (or perform...
5
by: PeteCresswell | last post by:
Access tends to take over my machine when I run long queries. The queries in question are Append queries. Some of the jobs we're talking about run 45 minutes to an hour...so the loss in...
1
by: Aaron | last post by:
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; ...
4
by: deko | last post by:
I'm a little nervous about slamming my database with a dozen Update queries in a loop that all modify RecordSources of open forms. Will the use of DoEvents and/or a Sleep function ameliorate any...
10
by: shumaker | last post by:
I don't need a detailed description of a solution(although I wouldn't mind), but I am hoping someone could tell me in general the best path to go about accomplishing a task, since I don't know all...
2
by: Jim S | last post by:
To my surprise and chagrin, newer versions of Access have disabled the functionality that lets users change the data in linked tables that point to a range in an Excel workbook. This is "because of...
6
by: falbrech_www | last post by:
Hi all, we got here one database which has several linked tables, whereas the link points to several csv-files. Currently we also have 2 different queries using the linked tables. Now one of us...
1
by: austin1539 | last post by:
-Access 2002 -Windows XP Pro Trying to run a DELETE Query to delete each entry in the table 'Data' where the field 'AssocID' matches the field 'AssocID' in the table 'Queries' and the date is...
9
by: JJM0926 | last post by:
I'm trying to create a running totals query in access 97. I have followed the directions on how to do it from Microsofts website article id 138911. I took their code they had and replaced it with...
14
by: Supermansteel | last post by:
My team at work uses Cognos to run multiple queries to pull in data. Then they take that data and import into Access and then usually run an Append Query to run a RND function to pull out a few...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.