Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 2nd, 2004, 01:51 AM
Authorized User
 
Join Date: Jun 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem Connect to Access

Hi, I am new in .Net framework. Currently I am having problems connect to another server with VB .Net to MS Access database. I read similiar articles in this forum about the connection string to connect to Access but still failed. I do not know what's wrong.

My situation is that, currently there is a database file named DATA1 in SERVER1. This DATA1 is currently connected to another software called SOFTWARE1.

I copied DATA1 into my local harddisk and with the WebApplication(ASP .Net Web Application in VB .Net), which only retrieve info from DATA1 and display it in the forms. The connection is successful, with the connection string such as below:

Dim cn As New OleDb.OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DATA1.mdb;")


After finish testing, and wanting to connect to the DATA1 on SERVER1(Server1 is mapped as drive E:), I can't connect to it. I tried a connection string as below:(User ID with a blank password)

("Provider=Microsoft.Jet.OLEDB.4.0;Server=E:\DATA1 .mdb;User ID=Admin;Password=;")
*This give me an error of--Could not find installable ISAM.

Then, I tried connect to DATA1 using VB .Net through the server pool, and the connection was successful tested and linked. Therefore I copied the exactly connection string from the "property" such as below:

("Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=E:\DATA1.mdb;Mode=Share Deny None;Extended Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False")

*This give an error of--Format of the initialization string does not conform to specification starting at index 146.

There is no *.mdw in SERVER1 too, I does not know what went wrong, your help will be much much appreciate, I had been trying to find the answer for almost 2 days :
 
Old July 2nd, 2004, 08:28 AM
Authorized User
 
Join Date: Jul 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Mayur52o
Default

i think i found your problem

("Provider=Microsoft.Jet.OLEDB.4.0;Server=E:\DATA1.mdb;User ID=Admin;Password=;")

change to

("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\DATA1.mdb;User ID=Admin;Password=;")

Hope this helps

 
Old July 4th, 2004, 07:30 PM
Authorized User
 
Join Date: Jun 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yup that I test it too, it gives another kind of error:

The Microsoft Jet database engine cannot open the file 'E:\msdsback.mdb'. It is already opened exclusively by another user, or you need permission to view its data.

One of my friends said I can't get the permission bcoz the server does not installed the programmes it is needed. I am accessing to an Access database but the server didn't install MS.Access or .Net Framework in it. I am currently using Win2k as well. Is it also needed to assign ASPNET to the server in order to work? The server is used as a storage, I does not know whether additional installation of programmes is allowed, what must I do?

 
Old July 5th, 2004, 12:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

make a folder (ex: DB) & move ur mdb file into that!
set ur Connection string as [u]"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\db\DATA1.mdb;User ID=Admin;Password=;"</u>
& GIVE WRITE PRIMISION to ur DB folder.
& be sure it'll be ok.

Always:),
Hovik Melkomian.
 
Old July 5th, 2004, 01:30 AM
Authorized User
 
Join Date: Jun 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually the DATA1.mdb is in SERVER1\MSDS\DATA1.mdb, and I map straight to the MSDS folder. I checked with the folder and it is given "everyone" "FULL" permission already. Moreover I cannot move the .mdb file bcoz it is being used by other programmes currrently for insertion,update or delete functions. What I connect to the database is only to read from the query and display results in my application in VB.Net.

 
Old July 6th, 2004, 02:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

O I guess I got what u need. if u run ur page from a [u]Virtual Directory</u> & ur data file (DATA1.mdb) located there, u need MapPath! as
Code:
connectString ="Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= " & [u]Server.MapPath("DATA1.mdb")</u>
HTH.

Always:),
Hovik Melkomian.
 
Old July 6th, 2004, 07:32 PM
Authorized User
 
Join Date: Jun 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Really thanx for ur suggestion melvik, I am already out of clues, however, it still doesn't work.
I give a connection string such as below:
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= & Server.MapPath(DATA1.mdb);")

but it give me the following error:
Could not find file 'C:\WINNT\system32\& Server.MapPath(DATA1.mdb)


So I try another one:
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= E:\Server.MapPath(DATA1.mdb);")
(my SERVER1\MSDSPenang is mapped to drive E:)

and it give me the same permission error:
The Microsoft Jet database engine cannot open the file 'E:\Server.MapPath(DATA1.mdb)'. It is already opened exclusively by another user, or you need permission to view its data.

What else could it be?

 
Old July 6th, 2004, 10:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Hey there is nothing like:
<s>C:\WINNT\system32\& Server.MapPath(DATA1.mdb)</s>
or <s>E:\Server.MapPath(DATA1.mdb)</s>
read Server.MapPath & see what it returns?! I guess ur problem is there!

I said if u run ur page from [u]Virtual Directory</u> like: [u]localhost\testVD</u> & ur sourse r in [u]E:\testVD</u> MapPath will return E:\testVD\DATA1.mdb

Try to give exact location instead of MapPath & Then u should see ur result, MapPath will make ur location dynamic.

HTH.

Always:),
Hovik Melkomian.
 
Old July 7th, 2004, 04:48 AM
Authorized User
 
Join Date: Jun 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am terribly sorry if I din make my situation clear.

I run my page from :\localhost\MSDS but I am trying to connect to my source which is in another network.
Let's say it is on a server called ServerA, in a directory called DirectoryA. So I mapped my drive E: to //ServerA/DirectoryA
The location of my database is fixed.

Thanx in advance.

 
Old July 7th, 2004, 08:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Ok- umm........ How about using the quotes in the right place? Your including the server.mappath() in the quotes.. so it's not running the function...

Code:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="  & Server.MapPath(DATA1.mdb) & ";")
Would work a bit better... Your trying to open a file that doesn't exist named server.mappath(data1.mdb).. the error is what I'd expect to see in this case.

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee





Similar Threads
Thread Thread Starter Forum Replies Last Post
connect to access paul20091968 Excel VBA 1 January 16th, 2007 04:07 AM
HOW TO programatically connect to Access Database Deepa7476 Visual Basic 2005 Basics 4 May 23rd, 2006 09:12 AM
Connect textbox to Access field aya_hbkenshin04 Classic ASP Databases 0 May 3rd, 2006 12:52 PM
How to connect to an MS Access database? petercahyadi Java Databases 3 February 22nd, 2005 07:28 PM
Cannot Connect to Access DB mjmfgm Classic ASP Databases 8 March 9th, 2004 07:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.