0

I am using an Access Database through Visual Basic 6.
Is there any other way to access the database excluding the following code.

Set CNN = New ADODB.Connection
str = "\\SYS8\DATAX\EMP.MDB"
CNN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + str + ";Persist Security Info=False"
CNN.CursorLocation = adUseClient

3
Contributors
4
Replies
9
Views
9 Years
Discussion Span
Last Post by plusplus
0

I'm not sure why you don't like the code you have if it works, but just in case you're interested, this is the way I ususally do it:


Dim wrkJet As Workspace
Dim dbProgram As Database
Dim wOrders As Recordset
Set wrkJet = CreateWorkspace("", "Admin", "", dbUseJet)
Set dbProgram = wrkJet.OpenDatabase("myDBName.mdb")
Set wOrders = dbProgram.OpenRecordset("SELECT * FROM Orders ORDER BY OrderNumber", dbOpenSnapshot)
.
.
.

0

Thanks.

but here also

Dim wrkJet As Workspace
Dim dbProgram As Database
Dim wOrders As Recordset
Set wrkJet = CreateWorkspace("", "Admin", "", dbUseJet)
Set dbProgram = wrkJet.OpenDatabase("myDBName.mdb")
Set wOrders = dbProgram.OpenRecordset("SELECT * FROM Orders ORDER BY OrderNumber", dbOpenSnapshot)

we have to give the path.
Actually I have done my work using the above one but
I just want to know is there any method or technique to use MS Access DB without using Path.

0

Where do you want to get the name of the database from? The choices are to hard code it, (not your favorite obviously), to pass it as a parameter to the application via the command line (not my favorite approach), to store it in a parameter file, the name of which can be specified on the command line used to open the application (my favorite approach), to create a form that asks the user to enter it. Maybe you can think of some other ways as well.

Name your poison,

Hoppy

0

I put the path in my main sub of main module and call it strdb.
In the code I always write
CNN.open strdb
this way when there is a change you change it in the module and not every time you used the connection string

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.