PC Review


Reply
Thread Tools Rate Thread

Connection String To Access With Workgroup File

 
 
Joe
Guest
Posts: n/a
 
      30th Nov 2008
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
 
Reply With Quote
 
 
 
 
Gregory Beamer
Guest
Posts: n/a
 
      30th Nov 2008
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! |
********************************************

"Joe" <(E-Mail Removed)> wrote in message
news:760616bc-0c39-4216-a024-(E-Mail Removed)...
> 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


 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      10th Dec 2008
Try a single quote around the filename. Especially since you have spaces.

I hope the code below is only demonstration code, and you're not actually
hardcoding filenames into your code.

I have a JET DATABASE (better term to use instead of an "Access database")
example here:

http://sholliday.spaces.live.com/blog/cns!A68482B9628A842A!176.entry

Which has the connections strings in the config correctly.




"Joe" <(E-Mail Removed)> wrote in message
news:760616bc-0c39-4216-a024-(E-Mail Removed)...
> 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



 
Reply With Quote
 
agile
Guest
Posts: n/a
 
      11th Dec 2008
check 2
 
Reply With Quote
 
agile
Guest
Posts: n/a
 
      11th Dec 2008
check 2
 
Reply With Quote
 
agile
Guest
Posts: n/a
 
      11th Dec 2008
check 2
 
Reply With Quote
 
agile
Guest
Posts: n/a
 
      12th Dec 2008
check 2
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
workgroup access connection from excel =?Utf-8?B?U2Vhbg==?= Microsoft Excel Programming 1 25th Aug 2006 06:11 PM
ADO connection with workgroup Access database =?Utf-8?B?Y2ExMzU4?= Microsoft Excel Programming 4 21st Jun 2006 06:13 AM
ADO connection with workgroup Access Database =?Utf-8?B?Y2ExMzU4?= Microsoft Access VBA Modules 0 20th Jun 2006 07:44 PM
RE: Adding Workgroup file to provider string Eric Butts [MSFT] Microsoft Access Security 0 1st Jul 2004 12:13 AM
Connection String with Access Workgroup Info (mdw) Duppypog Microsoft ADO .NET 2 18th Aug 2003 09:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:43 AM.