473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help on using Ms access and DSN

Hi everybody,

Im trying to access a Ms Access database outside my root website
folder, so Im using ODBC DSN. I have already the DSN create and
working (this same DSN is used by many classic ASP websites I have
running on my remote server). Im also have latest ODBC and JET drivers
installed.

My code is something like this:

Dim objConn As New OdbcConnection
objConn.ConnectionString = "DSN=MyDSN;"

objConn.Open()

Const strSQL As String = "SELECT * FROM customers"
Dim objCmd As New OdbcCommand(strSQL, objConn)

However when I try to run this I always get the error "ERROR [IM002]
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified" on the line that opens the connection ->
objConn.Open()

Any sugestion why is this happening? Or perhaps some turnaround on how
to access a MS Access database that is outside my root webfolder.

Any help is higly appreciated

Thanks in advance

Joao

Jul 24 '07 #1
4 1488
<jo*************@gmail.comwrote in message
news:11**********************@w3g2000hsg.googlegro ups.com...
Any help is higly appreciated
Use OleDb.

objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=F:\MyDatabase.mdb;User Id=admin;Password=;"

The Jet database doesn't have to be in your site's virtual directory, but it
does have to be in a folder which is "visible" to ASP.NET, and on which the
user under which ASP.NET is running has write access...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 24 '07 #2
Hi Mark

actually that was my initialy attempt to achieve my goal, however when
im using oledb I got a diferent error

My code was something like this

Dim objConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("../../WebDBs/websitex/
myDatabase.mdb"))
objConn.Open()

And I got this error: Cannot use a leading .. to exit above the top
directory.

Then after some research I read someone advising to use a DSN for data
bases outside our website folder.

Probably im getting ythat error because, as you said the folder where
I have the DB is not visible to the ASP.NET.

My folder structure is like this:
DB-D:\webdbs\website\myDatabase.mdb
Website -D:\premierweb\websitex\default.aspx

I have a browseable virtual directory to D:\premierweb where I have
all my sites.

So, I want to access myDatase.mdb from default.aspx. How can I make
the db folder visible to my website in a securily way? Any sugestion?

Thanks in advance

Joao

On Jul 24, 1:20 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<joaotsetsemo...@gmail.comwrote in message

news:11**********************@w3g2000hsg.googlegro ups.com...
Any help is higly appreciated

Use OleDb.

objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=F:\MyDatabase.mdb;User Id=admin;Password=;"

The Jet database doesn't have to be in your site's virtual directory, but it
does have to be in a folder which is "visible" to ASP.NET, and on which the
user under which ASP.NET is running has write access...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

Jul 24 '07 #3
<jo*************@gmail.comwrote in message
news:11*********************@w3g2000hsg.googlegrou ps.com...
Dim objConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("../../WebDBs/websitex/
myDatabase.mdb"))
objConn.Open()

And I got this error: Cannot use a leading .. to exit above the top
directory.
Yes, that would be correct. There are several tricks you could do to resolve
virtual and relative directories to absolute filespecs, but by far the
simplest solution is to specify the full path to your Jet database in the
connection string, as I demonstrated.
Then after some research I read someone advising to use a DSN for data
bases outside our website folder.
Can't imagine why anyone would have said that...
So, I want to access myDatase.mdb from default.aspx. How can I make
the db folder visible to my website in a secure way? Any sugestion?
Dim objConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=D:\webdbs\website\myDatabase.mdb;"))

You may need to specify other parameters in your connection string...

Finally, the user account that ASP.NET is running under will need to have
write permission on the D:\webdbs\website folder.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 24 '07 #4
Just to let you know that problem is solved using the full path
solution.

I also found another way, probably one of the several tricks you said.

System.IO.FileInfo(System.IO.Path.Combine(Server.M apPath("."),
"../../../WebDBs/websitex/mydatabase.mdb")).FullName.

One way or another it's working

Many thanks for your help.

Joao

On Jul 24, 2:27 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
<joaotsetsemo...@gmail.comwrote in message

news:11*********************@w3g2000hsg.googlegrou ps.com...
Dim objConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("../../WebDBs/websitex/
myDatabase.mdb"))
objConn.Open()
And I got this error: Cannot use a leading .. to exit above the top
directory.

Yes, that would be correct. There are several tricks you could do to resolve
virtual and relative directories to absolute filespecs, but by far the
simplest solution is to specify the full path to your Jet database in the
connection string, as I demonstrated.
Then after some research I read someone advising to use a DSN for data
bases outside our website folder.

Can't imagine why anyone would have said that...
So, I want to access myDatase.mdb from default.aspx. How can I make
the db folder visible to my website in a secure way? Any sugestion?

Dim objConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=D:\webdbs\website\myDatabase.mdb;"))

You may need to specify other parameters in your connection string...

Finally, the user account that ASP.NET is running under will need to have
write permission on the D:\webdbs\website folder.

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

Jul 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: Vladislav Moltchanov | last post by:
Recently I have changed from Acc97 to Acc2000 (I had to supply some data entry tools for field data collection for users still using Acc97). Among lot of other complications coming with Acc2000...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
5
by: Steve Patrick | last post by:
Hi All You guys are my last hope, despite spending money on books and hours reading them I still can not achieve the results I need. I have designed a database in Access 2000 based on 1 table,...
1
by: Tim Hunter | last post by:
Hi, I am using Access 2003 with WinXP/sp#2. I have built a Help file using MS HTML Help Workshop that includes a TOC as well as an Index file. My problem is how do I call this from Access. I do...
9
by: | last post by:
Hi All, I have allready tried to ask a similar question , but got no answer until now. In the meantime, I found, that I cannot understand some thread-settings for the Main() function . If I use...
8
by: D P | last post by:
Hello everyone, I am new here and I hope I can get the help I need. I will be as descriptive as possible!! I have developed an app using VB.NET that requires making a connection to an access...
28
by: Siv | last post by:
Hi, If I run the following: strSQL = "Select * FROM Clients;" da = New OleDb.OleDbDataAdapter(strSQL, Conn) 'Create data adapter cb = New OleDb.OleDbCommandBuilder(da) ...
0
NeoPa
by: NeoPa | last post by:
Introduction: This seems like a very straightforward topic. Why would anyone need help finding MS Access Help related to this topic? I can't really answer that except to say that I know from...
9
by: O | last post by:
I need to do some lookups and updates on some legacy Access 2.0 files (they've from another vendor and I'm not in a position to update them). I was successful using VB6, but I've moved on to VS...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.