problems with connection string

Aiken_Bob

Member
Joined
Jun 25, 2010
Messages
11
Programming Experience
Beginner
I'm running out of options. I have a visual basic 2008 program that uses an Access DB with no problems. DB opens any I perform many queries

I recently tried to use another Access DB and the connection fails to open each time. Both DB's are the access-2007 version.

Are there certain options in access that could have been reset?

Thanks
 
Perhaps you could show us your code, your connection string and the error message. That way we can make a proper diagnosis based on evidence rather than just guessing.
 
Here is the code --- I've tested to see if the DB file exists and it does -- I have, (I hope) it is a simple oversight - but for the life of me I can't see it.



Imports System.Data.OleDb
Imports System.IO
Module BasicModule
' data reader information
Public CnLocalDB As New OleDbConnection
Public blnConnectedToDB As Boolean


...

CnLocalDB.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strDBLocation & strDBName
Try
'CnLocalDB = New OleDbConnection(CnLocalDB.ConnectionString)
CnLocalDB.Open()
blnConnectedToDB = True
Catch ex As Exception
blnConnectedToDB = False
MsgBox("Having problems making the connection to the DB connection string " & vbCrLf & CnLocalDB.ConnectionString)
End Try
 
The error message is provided by ex.Message, and the Exception name and stack trace by ex.ToString.
You have probably verified what the connection string expands to.
 
probably missing the obvious -- but don't understand your response. I've traced the CnLocalDB object and it clearly identifies the connection strring but fails to open
 
You haven't shown us your connection string. You've only shown us the code that creates your connection string. Have you viewed the actual connection string itself? My guess is that it's not what you think it is, but we can't really be sure from what you've posted.
 
Sorry,
Here is the actual connection string

Data Source=D:\Projects\WorldData\Country.accdb; Provider=microsoft.ACE.OLEDB.12.0;

I have tested, via File.Exist to make sure the file is in fact there. I have also added the "Persist Security Info" parameter with no effect. The crazy thing is that the same code works in other applications.
Thanks for your help so far...
 
Back
Top