View Full Version : VS 2005 Help on Access MDB's


ShimmyShamrock
09-07-2006, 06:32 AM
Greetings,

I have an application written in VB 5, which opens an Access 97 MDB, executes stored queries - that's it! Simple enough. Now, I've upgraded my Access 97 MDB to Access 2003 MDB to point to an Oracle 10G server.

However, I've upgraded to VS 2005 (yikes) and proceeded with the upgrade wizard - it broke everything!

I wondering if anyone could provide a simple translation for the following VB5 code to VS 2005 without using the "Add Data Sources" stuff.


Dim db As DAO.Database
Dim qd As DAO.QueryDef

Set db = OpenDatabase("ACCESS97.MDB")

Set qd = db.QueryDefs("BUILD LOCAL TABLE FROM ODBC SOURCE")
qd.Execute


Thanks so much.

skea
10-05-2006, 08:32 PM
here is the translation.
.....
1) Create a connection string to your database
2) Create a command object
3) Create a stored query or Procedure in access using CREATE PROC
3) Open the connection.
4) ExecuteNonQuery against the command object
5) Close and dispose the objects.
.....You MIGHT have to drop the PROC first as well, so use DROP PROC for that.

Below is how to create a procedure in access

CREATE PROC myproc AS
SELECT * FROM TABLENAME;