PC Review


Reply
Thread Tools Rate Thread

Connecting to Jet 4.0/Access database

 
 
Peter Rabbit
Guest
Posts: n/a
 
      14th Jul 2003
My attempts to open a Jet database in CSharp .Net fail. I am trying the
following:
string cstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents and
Settings/.../Data/List.mdb;Connect Timeout=5";

OleDbConnection sdb = new OleDbConnection(cstr);

sdb.Open();

but the Open generates an OleDbException. Is there soemthing wrong with the
connection string?

Thanks

--
Peter Aspey
-------------------------------------------------------
email: replace 6 by p


 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      14th Jul 2003
Typically, the error message will have more specifics: unauthorized user,
could not find file, etc. What message is in the exception?

"Peter Rabbit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> My attempts to open a Jet database in CSharp .Net fail. I am trying the
> following:
> string cstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents

and
> Settings/.../Data/List.mdb;Connect Timeout=5";
>
> OleDbConnection sdb = new OleDbConnection(cstr);
>
> sdb.Open();
>
> but the Open generates an OleDbException. Is there soemthing wrong with

the
> connection string?
>
> Thanks
>
> --
> Peter Aspey
> -------------------------------------------------------
> email: replace 6 by p
>
>



 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      15th Jul 2003
On Mon, 14 Jul 2003 21:27:57 +0200, "Peter Rabbit" <(E-Mail Removed)> wrote:

¤ My attempts to open a Jet database in CSharp .Net fail. I am trying the
¤ following:
¤ string cstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents and
¤ Settings/.../Data/List.mdb;Connect Timeout=5";
¤
¤ OleDbConnection sdb = new OleDbConnection(cstr);
¤
¤ sdb.Open();
¤
¤ but the Open generates an OleDbException. Is there soemthing wrong with the
¤ connection string?

Yes, you need to escape the slash character in your database file path:

OleDbConnection objConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\\My
Documents\\db1.mdb");


Paul ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
Peter Rabbit
Guest
Posts: n/a
 
      15th Jul 2003
Thanks for your response. After enclosing the Open function in a 'try'
clause, the Exception object gave the message:
"Multiple-step OLE DB operation generated errors. Check each OLE DB status
value, if available. No work was done."

I don't know if that helps. "Each OLE DB status value" - where do I find
these values?

--
Peter Aspey
-------------------------------------------------------
email: replace 6 by p

"Marina" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Typically, the error message will have more specifics: unauthorized user,
> could not find file, etc. What message is in the exception?
>
> "Peter Rabbit" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > My attempts to open a Jet database in CSharp .Net fail. I am trying the
> > following:
> > string cstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents

> and
> > Settings/.../Data/List.mdb;Connect Timeout=5";
> >
> > OleDbConnection sdb = new OleDbConnection(cstr);
> >
> > sdb.Open();
> >
> > but the Open generates an OleDbException. Is there soemthing wrong with

> the
> > connection string?
> >
> > Thanks
> >
> > --
> > Peter Aspey
> > -------------------------------------------------------
> > email: replace 6 by p
> >
> >

>
>



 
Reply With Quote
 
Peter Rabbit
Guest
Posts: n/a
 
      15th Jul 2003
Sorry, the quote I gave was misleading. I had tried forward slashes. The
backslashes are in fact 'escaped' in the real version, and the problem is
the same.

Thanks
--
Peter Aspey
-------------------------------------------------------
email: replace 6 by p

"Paul Clement" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Mon, 14 Jul 2003 21:27:57 +0200, "Peter Rabbit" <(E-Mail Removed)>

wrote:
>
> ¤ My attempts to open a Jet database in CSharp .Net fail. I am trying the
> ¤ following:
> ¤ string cstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents

and
> ¤ Settings/.../Data/List.mdb;Connect Timeout=5";
> ¤
> ¤ OleDbConnection sdb = new OleDbConnection(cstr);
> ¤
> ¤ sdb.Open();
> ¤
> ¤ but the Open generates an OleDbException. Is there soemthing wrong with

the
> ¤ connection string?
>
> Yes, you need to escape the slash character in your database file path:
>
> OleDbConnection objConn = new

OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\\My
> Documents\\db1.mdb");
>
>
> Paul ~~~ (E-Mail Removed)
> Microsoft MVP (Visual Basic)



 
Reply With Quote
 
Peter Rabbit
Guest
Posts: n/a
 
      15th Jul 2003
Open now works! I limited the arguments in the connection string to
'Provider' and 'Data Source' only (i.e. removed the 'Connect Timeout').
So don't waste any time on my last message!
Thanks again

--
Peter Aspey
-------------------------------------------------------
email: replace 6 by p

"Marina" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Typically, the error message will have more specifics: unauthorized user,
> could not find file, etc. What message is in the exception?
>
> "Peter Rabbit" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > My attempts to open a Jet database in CSharp .Net fail. I am trying the
> > following:
> > string cstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Documents

> and
> > Settings/.../Data/List.mdb;Connect Timeout=5";
> >
> > OleDbConnection sdb = new OleDbConnection(cstr);
> >
> > sdb.Open();
> >
> > but the Open generates an OleDbException. Is there soemthing wrong with

> the
> > connection string?
> >
> > Thanks
> >
> > --
> > Peter Aspey
> > -------------------------------------------------------
> > email: replace 6 by p
> >
> >

>
>



 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      16th Jul 2003
On Tue, 15 Jul 2003 19:20:10 +0200, "Peter Rabbit" <(E-Mail Removed)> wrote:

¤ Sorry, the quote I gave was misleading. I had tried forward slashes. The
¤ backslashes are in fact 'escaped' in the real version, and the problem is
¤ the same.

Could you post the code with the exact connection string you are using.


Paul ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      16th Jul 2003
On Tue, 15 Jul 2003 19:40:12 +0200, "Peter Rabbit" <(E-Mail Removed)> wrote:

¤ Open now works! I limited the arguments in the connection string to
¤ 'Provider' and 'Data Source' only (i.e. removed the 'Connect Timeout').
¤ So don't waste any time on my last message!

In that case ignore my follow-up question.


Paul ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
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
Connecting to an Access database NateBuckley Microsoft Excel Programming 3 6th May 2008 01:29 PM
Need help in VB.NET connecting to Access database CM Manager via DotNetMonster.com Microsoft VB .NET 10 21st Aug 2005 01:12 AM
connecting to access 97 database is same as SQL? =?Utf-8?B?QWw=?= Microsoft VB .NET 5 13th Jan 2005 05:37 PM
connecting to an Access Database =?Utf-8?B?WmFmYXI=?= Microsoft Dot NET Compact Framework 1 3rd Nov 2004 03:40 PM
CONNECTING AN ACCESS DATABASE (HELP!!!) DALHART DOBBS Microsoft Access 3 23rd Mar 2004 04:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:16 PM.