|
-
Feb 7th, 2006, 09:58 AM
#1
Thread Starter
Fanatic Member
specify default directory with OLEDB
When using ODBC connectivity you can specify a DefaultDir. But with OLEDB you can't use the DefaultDir setting, is there an OLEDB equivalent?
VB Code:
' CONNECTION STRING FOR THE DATABASE
' AccessConnect = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
' "DBQ=Westfield.MDB;" & _
' "DefaultDir=" & App.Path & ";"
AccessConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=Westfield.mdb;"
He who never made a mistake never made a discovery?
-
Feb 7th, 2006, 10:06 AM
#2
Re: specify default directory with OLEDB
You should specify it as part of the Data Source parameter, ie:
VB Code:
AccessConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\Westfield.mdb;"
-
Feb 7th, 2006, 10:08 AM
#3
Thread Starter
Fanatic Member
Re: specify default directory with OLEDB
thanks let me try that
He who never made a mistake never made a discovery?
-
Feb 7th, 2006, 10:21 AM
#4
Thread Starter
Fanatic Member
Re: specify default directory with OLEDB
Ok, I did that but I must have another issue. I am trying to switch from ODBC to OLEDB, so in my module I am createing a connection. I need to modify my ODBC connection to the new OLEDB. But it appears that I something is wrong. I am getting errors when I call my connection. I guess I need to make some additional changes.
3709,"The connection cannot be used to perform this operation. It is either closed or invalid in this context.","This error created on:",#2006-02-07 10:07:19#
This is how I have my connection in my module set up. As you can see I was using ODBC.
VB Code:
Sub CreateConnection(objConn As Connection)
' CONNECTION STRING FOR THE DATABASE
' AccessConnect = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
' "DBQ=Westfield.MDB;" & _
' "DefaultDir=" & App.Path & ";"
AccessConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source==" & App.Path & "\Westfield.mdb;"
'MsgBox AccessConnect
' Create Connection Object and open it
Set objConn = New ADODB.Connection
objConn.CursorLocation = adUseClient
' Trap any error/exception
On Error GoTo AdoError
objConn.ConnectionString = AccessConnect
objConn.Open
Exit Sub
' ADO Error/Exception Handler
AdoError:
ErrNumber = Err.Number
ErrSource = Err.Source
ErrDescription = Err.Description
'AdoErrorEx List1, objConn
End Sub
This is how I was calling it from within appilcation, it bombs out on this line and gives me the error above.
.ActiveConnection = objConn
VB Code:
'connect to database, generate ID, add ID to text box
Call CreateConnection(objConn)
'MsgBox objConn.State
Set objRs = New ADODB.Recordset
With objRs
.ActiveConnection = objConn
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Source = "select * from Campaign where 2=3" '2=3 basically creates a empty record set
.Open
End With
' ADDING RECORDS FROM TEXTBOX TO DATABASE
With objRs
....
He who never made a mistake never made a discovery?
-
Feb 7th, 2006, 10:53 AM
#5
Re: specify default directory with OLEDB
The Connection is not open when it is used as an ActiveConnection.
The CreateConnection procedure should be generating an error because you have two == signs after Data Source.
Code:
AccessConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source==" & App.Path & "\Westfield.mdb;"
-
Feb 7th, 2006, 10:57 AM
#6
Thread Starter
Fanatic Member
Re: specify default directory with OLEDB
Man.. what dumb oversight
Thanks its working now.
He who never made a mistake never made a discovery?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|