|
-
Nov 10th, 2003, 09:58 AM
#1
Thread Starter
Hyperactive Member
beginner's question
I'm trying to connect to database using a ASP.NET Web Application.
I drag and drop an OleDbConnection control and then import files,
provide the connection string and test connection to Access NWIND.mdb
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.Data.OleDb
then in the page_load event
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Try
OleDbConnection1.Open()
Response.Write("Success")
Catch dbException As OleDbException
Response.Write("Unable to open database")
End Try
End Sub
It says Unable to open database.
Whereas I do the same steps in Windows application it gets connected to the same database just fine.
I can't figureout what am I doing wrong?
-
Nov 10th, 2003, 10:12 AM
#2
New Member
i think u are missing some lines of code. u need to look not only in ur form_load sub. Search after e.g. OleDbConnection1 declaration maybe at the top somewhere...
-
Nov 10th, 2003, 11:04 AM
#3
Thread Starter
Hyperactive Member
-
Nov 10th, 2003, 11:17 AM
#4
Thread Starter
Hyperactive Member
I'm track the error and I get
The Microsoft Jet database engine cannot open the file 'C:\Inetpub\wwwroot\Database\login.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
Whereas if I try to open it with VB.NET application it opens just fine!
-
Nov 10th, 2003, 12:14 PM
#5
PowerPoster
Make sure the directory contaning the access file has read access and is granted to the ASPNET account.
-
Nov 10th, 2003, 12:17 PM
#6
Thread Starter
Hyperactive Member
I tried it in the same directory under wwwroot and also ouside it.
The directory is not read only. Also pleae explain what do you mean by 'and is granted to the ASPNET account'
-
Nov 11th, 2003, 03:45 AM
#7
New Member
try using this connectionstring for ur db:
Code:
"Provider=Microsoft.Jet.OLEDB.4.0; data source=" & C:\Inetpub" & _
"\wwwroot\Database\NWIND.MDB"
or just remove that "Mode=Share Deny None" thing, maybe that works also, or find some other proberty for that mode.
one more thing, u could write in ur try catch code not only "Unable to open database" evenmore u could use "dbException.message" that will return the exactly errormessage. And dont forget to close ur dbconnection when u finished with ur access to it.
greetings
p.s.: if u restart ur iis it should work again too, but u should do this only on ur local machine ^^
Last edited by PJ6; Nov 11th, 2003 at 03:50 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|