473,402 Members | 2,055 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,402 software developers and data experts.

Executing Access Query

Art
Hi,

Can anyone point me to an example of how I would execute a query I've created in an Access DB. I've copied the SQL down to my VB.net application and that works fine, but it's ugly. I'd like to direcly execute the query that I created in Access - if possible.

Also, I would like to be able to add a parameter to that query. For example, if I'm in Access and put an unknown field in the query, I get prompted to enter that info when the query runs. I'm hoping that can also be done through VB.net.

Art
Nov 20 '05 #1
5 3612
Hi Art,

It can that you mean something completly else with your query, however when
this link is not the answer and you mean something totally else, please do
than reply and tell what you mean with an Access Query, this is not an
access newsgroup you know.

Access Automate
http://support.microsoft.com/default...b;EN-US;317113

However, I hope this helps a little bit?

Cor
Can anyone point me to an example of how I would execute a query I've created in an Access DB. I've copied the SQL down to my VB.net application
and that works fine, but it's ugly. I'd like to direcly execute the query
that I created in Access - if possible.
Also, I would like to be able to add a parameter to that query. For example, if I'm in Access and put an unknown field in the query, I get
prompted to enter that info when the query runs. I'm hoping that can also
be done through VB.net.
Art

Nov 20 '05 #2
Art
Cor,

Thanks for the link. I'm trying to work with an Access Database in VB.net. I've seen how to read through records, submit SQL code, and write information back. I've also seen some examples about how to execute stored procedures in SQL Server. It starts with importing System.Data.SqlClient. I had been assuming that this is specific to SQL Server and would not work with MS Access -- but I don't really know (I confess that I should have tried).

I will read through the material on the link that you sent to me.

Art

"Cor Ligthert" wrote:
Hi Art,

It can that you mean something completly else with your query, however when
this link is not the answer and you mean something totally else, please do
than reply and tell what you mean with an Access Query, this is not an
access newsgroup you know.

Access Automate
http://support.microsoft.com/default...b;EN-US;317113

However, I hope this helps a little bit?

Cor
Can anyone point me to an example of how I would execute a query I've

created in an Access DB. I've copied the SQL down to my VB.net application
and that works fine, but it's ugly. I'd like to direcly execute the query
that I created in Access - if possible.

Also, I would like to be able to add a parameter to that query. For

example, if I'm in Access and put an unknown field in the query, I get
prompted to enter that info when the query runs. I'm hoping that can also
be done through VB.net.

Art


Nov 20 '05 #3
Hallo Art,

You can use those samples and everywhere where you see this

SqlClient.SQL you change it for OleDb.OleDb

the only difference it that you have to make an access connection which is
as easy as

Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;" &
_
" Data Source=C:\db1.mdb;User Id=admin;Password=;")

I hope this helps to get a even a quicker start.

Cor
Nov 20 '05 #4
Hi Art,

I was mixing you up with another message however with your new message I
would take this as reference (that link I had send also some hours ago and
send it as well to that new message).

VB.net Resource kit
http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing the resource kit
http://msdn.microsoft.com/vbasic/vbr...q/#installvdir

Another resource for learning is the Quick Starts
http://samples.gotdotnet.com/quickstart/

My message about SQL and Access stays with this the same.
I hope this helps a little bit?

Cor
"Art" <Ar*@discussions.microsoft.com> schreef in bericht
news:B8**********************************@microsof t.com...
Cor,

Thanks for the link. I'm trying to work with an Access Database in VB.net. I've seen how to read through records, submit SQL code, and write
information back. I've also seen some examples about how to execute stored
procedures in SQL Server. It starts with importing System.Data.SqlClient.
I had been assuming that this is specific to SQL Server and would not work
with MS Access -- but I don't really know (I confess that I should have
tried).
I will read through the material on the link that you sent to me.

Art

"Cor Ligthert" wrote:
Hi Art,

It can that you mean something completly else with your query, however when this link is not the answer and you mean something totally else, please do than reply and tell what you mean with an Access Query, this is not an
access newsgroup you know.

Access Automate
http://support.microsoft.com/default...b;EN-US;317113

However, I hope this helps a little bit?

Cor
Can anyone point me to an example of how I would execute a query I've

created in an Access DB. I've copied the SQL down to my VB.net application and that works fine, but it's ugly. I'd like to direcly execute the query that I created in Access - if possible.

Also, I would like to be able to add a parameter to that query. For

example, if I'm in Access and put an unknown field in the query, I get
prompted to enter that info when the query runs. I'm hoping that can also be done through VB.net.

Art


Nov 20 '05 #5
On Mon, 21 Jun 2004 07:18:02 -0700, Art <Ar*@discussions.microsoft.com> wrote:

¤ Hi,
¤
¤ Can anyone point me to an example of how I would execute a query I've created in an Access DB. I've copied the SQL down to my VB.net application and that works fine, but it's ugly. I'd like to direcly execute the query that I created in Access - if possible.
¤
¤ Also, I would like to be able to add a parameter to that query. For example, if I'm in Access and put an unknown field in the query, I get prompted to enter that info when the query runs. I'm hoping that can also be done through VB.net.
¤
¤ Art

Here is an example of how to execute an Access QueryDef and place the contents of the Select query
into a DataSet:

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
AccessCommand.Parameters.Add("@ParamName", System.Data.OleDb.OleDbType.VarWChar).Value =
"SomeValue"

Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter

With da
.SelectCommand = AccessCommand
End With

Dim ds As New DataSet("QueryTables")
da.Fill(ds, "Table1")
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #6

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

Similar topics

7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
1
by: Job Lot | last post by:
I have written 6 Queries in an Access DB, which are executed in a For Each…Next loop to populate DataSet object. A new DataTable object is created in DataSet for each query, as follows Private...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
7
by: Glenn Davy | last post by:
Hidely hodley everyone I'd like to run a series of of sql ddl statements against an msde2000 server. Normally I just deploy cmd file that impliments as osql statement, but I'd like to store the...
20
by: Neil Robbins | last post by:
I am trying to execute a make table query in my vb.net program. The db that I am accessing is an Access 2000 format db. The SQL code that I am using has been cut and pasted from the SQL View having...
3
by: Water Cooler v2 | last post by:
Dang! A *simple* query doesn't run on my machine. I wrote a Data Access Layer (DAL) in a dll that I am testing with the help of a console application. Here's the code. I am damn sure that my...
0
rpk2006
by: rpk2006 | last post by:
I have created a query to retrieve certain results and a report that is connected to this query. This query asks for date parameter to retrieve results. It looks somewhat like this: Select...
8
by: Daz | last post by:
Hi everyone. I was faced with the choice of whether my problem is indeed a PHP problem or a MySQL. I have decided it's a PHP problem as I don't experience the same problem when I execute the...
1
by: jesmi | last post by:
my code is: U]employee.cfm <html> <head> <title>Employee List</title> </head> <body> <h1>Employee List</h1>
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...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.