Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Access queries from VB.Net...

Status
Not open for further replies.

Ajb2528

Technical User
Feb 22, 2002
270
GB
I have an Access2000 mdb which I am coverting to VB.Net. The current Access application has numerous queries/querydefs that I would like to use within the VB.Net application. If anyone can help me it would be gratefully appreciated!!! It would save me hours/days of SQL coding!!

Regards,

Alan
 
Hey Alan,

It's actually pretty easy to re-use those queries. When you're doing your data access code, just set the name of your command.commandttext to be the name of the query (and set the command type to stored procedure...or whatever the value is for the OLEDB provider...sorry, I'm a sql server guy myself so its been a while since I had to connect to Access).

hth

D'Arcy
 
If your using Access, you can just go to the query, change it to the SQL View, and copy and paste it into your code. You will have to make some small adjustments, but nothing major.
 
Well, you could do that too. But having in-code sql statements is generally frowned upon. That's why if you're using SQL Server, its suggested to use stored procedures instead.

Access has a similar set up, except instead of stored procedures they're just called Queries (and they don't have the same flexibility that SP's have with the T-SQL language). But you can still mimic what's considered the better design.

D
 
Thanks for replies....

What I am really after is a way to mimic the following VB/VBA code in VB.Net where sql is a valid SQL statement...

Dim qdfnew As querydef
With db
.querydefs.delete("qryclaim")
qdfnew = .createquerydef("qryclaim", sql)
End With

Regards,

Alan
 
Hellooooooooooooooooooooooooooooooooooooo?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top