Connection String To Access With Workgroup File

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Hi,

I am attempting to connect by VB.NET program to a Microsoft
Access database which uses a workgroup file, but something is wrong
with my connection string. My code is shown below.

The error message that I get is: "Could not find
file ...Shortcut To Database.mdb"

But when I double-click on this file, everything behaves
normally. I double-checked the pathname and filename, no errors
there. So I am thinking that ADO.NET must do something different
when dealing with an Access database that uses a workgroup file, than
it does when a workgroup file is not involved.

Can anyone provide me any guidance on correct syntax for the
ConnectionString when a workgroup file is involved?

--------------------------------------------------------------------------
Public Function ConnectToDB() As Boolean
cnPCMTool = New System.Data.OleDb.OleDbConnection
cnPCMTool.ConnectionString = "Provider=Microsoft.Jet.OLEDB.
4.0;Data Source=C:\VS 2005 Projects\PCM Line Review\Shortcut To
Database.mdb"

If cnPCMTool.State = ConnectionState.Closed Then
Try
cnPCMTool.Open()
Return True
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
Return False
End Try
End If
End Function
 
Are there spaces in the name of the .mdb file? If so, I would change that
and try again. The other option is a messed up connection string.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 
Back
Top