ladykh
asked on
Open access database in asp.net.
Hi
I am trying to open an access database in an asp.net page to display some data but get the following error when running the page:
"The Microsoft Jet database engine cannot open the file 'C:\Inetpub\wwwroot\Practi ce2\test.m db'. It is already opened exclusively by another user, or you need permission to view its data".
Please can somebody help?
Thanks
I am trying to open an access database in an asp.net page to display some data but get the following error when running the page:
"The Microsoft Jet database engine cannot open the file 'C:\Inetpub\wwwroot\Practi
Please can somebody help?
Thanks
ASKER
I'm not sure where the IUSR account is (am trying to learn). Is it when you right click the practice2 directory then properties, then security? Or is it to do with the IIS server?
Thanks
Thanks
Are you running this on your local computer or on a web server? What is the operating system?
FtB
FtB
In any event, if you right click on the folder, go to properties, and then permissions, that might give you a starting point. If you are working with Windows XP rather than with a server, you may need to disable simple file sharing and then add the IUSR account (READ/WRITE) to the directory in question.
FtB
FtB
ASKER
Running on IIS Server on with windows xp. I have disabled simple file sharing and the same error message appears.
ladykh,
This link migh also help in understanding the porblem...
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q174/9/43.ASP&NoWebContent=1
http://support.microsoft.com/?scid=kb;en-us;Q306518
Happy programming...
This link migh also help in understanding the porblem...
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q174/9/43.ASP&NoWebContent=1
http://support.microsoft.com/?scid=kb;en-us;Q306518
Happy programming...
Good points above, particularly the "READ/WRITE permissions to the Practice2 directory" that Fritz suggested, which is usually the culprit in cases like this (that I've seen).
Also, even if it's not part of your current problem, do make sure that your code that opens the Connection object also closes that Connection when it is done with it. Otherwise, the MS Access lock file (LDB) that is created upon the Connection's opening may take awhile to get cleaned up, and successive attempts to access the database in the meantime may suffer a similar error.
Also, even if it's not part of your current problem, do make sure that your code that opens the Connection object also closes that Connection when it is done with it. Otherwise, the MS Access lock file (LDB) that is created upon the Connection's opening may take awhile to get cleaned up, and successive attempts to access the database in the meantime may suffer a similar error.
Thogek makes a very good point there--one that is too often ignored.
These articles are more geared to classic ASP but relate to the problems that you are experiencing:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q306518
http://www.webwizguide.info/asp/faq/access_database_faq.asp
FtB
These articles are more geared to classic ASP but relate to the problems that you are experiencing:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q306518
http://www.webwizguide.info/asp/faq/access_database_faq.asp
FtB
All of these above were true for ASP pages and partially for .net pages. I guess he/she talks about .net pages, so in that case you will also need to allow ASPNET user to use this mdb.
That's true, but that account is installed automatically with the .Net framework.
FtB
FtB
ASKER
Sorry for late reply but have been trying to get it to work but still comes up with same error.
Actually, I may be wrong about Jit's comment. Please see:
http://www.dotnet247.com/247reference/msgs/45/228153.aspx
FtB
http://www.dotnet247.com/247reference/msgs/45/228153.aspx
FtB
ASKER
I just have a very simple page with a button which when clicked I would like the data to be displayed in a datagrid. The above error appears when the button is clicked. Is it anything in the code that is the problem? The only bit I hand coded was near the bottom when button1 is clicked.
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg
Me.OleDbDataAdapter1 = New System.Data.OleDb.OleDbDat
Me.OleDbDeleteCommand1 = New System.Data.OleDb.OleDbCom
Me.OleDbConnection1 = New System.Data.OleDb.OleDbCon
Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCom
Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCom
Me.OleDbUpdateCommand1 = New System.Data.OleDb.OleDbCom
Me.DataSet11 = New Practice2.DataSet1
CType(Me.DataSet11, System.ComponentModel.ISup
'
'OleDbDataAdapter1
'
Me.OleDbDataAdapter1.Delet
Me.OleDbDataAdapter1.Inser
Me.OleDbDataAdapter1.Selec
Me.OleDbDataAdapter1.Table
Me.OleDbDataAdapter1.Updat
'
'OleDbDeleteCommand1
'
Me.OleDbDeleteCommand1.Com
" (photos_pref = ?) AND (skills_direct_pref = ?) AND (student_name = ? OR ? IS NU" & _
"LL AND student_name IS NULL)"
Me.OleDbDeleteCommand1.Con
Me.OleDbDeleteCommand1.Par
Me.OleDbDeleteCommand1.Par
Me.OleDbDeleteCommand1.Par
Me.OleDbDeleteCommand1.Par
Me.OleDbDeleteCommand1.Par
Me.OleDbDeleteCommand1.Par
'
'OleDbConnection1
'
Me.OleDbConnection1.Connec
"ocking Mode=1;Jet OLEDB:Database Password=;Data Source=""C:\Databases\alum
""";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provide" & _
"r=""Microsoft.Jet.OLEDB.4
"ded Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:" & _
"Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OL" & _
"EDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Databas" & _
"e=False"
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.Com
"udent_name) VALUES (?, ?, ?, ?)"
Me.OleDbInsertCommand1.Con
Me.OleDbInsertCommand1.Par
Me.OleDbInsertCommand1.Par
Me.OleDbInsertCommand1.Par
Me.OleDbInsertCommand1.Par
'
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.Com
"me FROM tblAlumni_pref"
Me.OleDbSelectCommand1.Con
'
'OleDbUpdateCommand1
'
Me.OleDbUpdateCommand1.Com
"ref = ?, student_name = ? WHERE (student_id = ?) AND (email_direct_pref = ?) AND" & _
" (photos_pref = ?) AND (skills_direct_pref = ?) AND (student_name = ? OR ? IS NU" & _
"LL AND student_name IS NULL)"
Me.OleDbUpdateCommand1.Con
Me.OleDbUpdateCommand1.Par
Me.OleDbUpdateCommand1.Par
Me.OleDbUpdateCommand1.Par
Me.OleDbUpdateCommand1.Par
Me.OleDbUpdateCommand1.Par
Me.OleDbUpdateCommand1.Par
Me.OleDbUpdateCommand1.Par
Me.OleDbUpdateCommand1.Par
Me.OleDbUpdateCommand1.Par
Me.OleDbUpdateCommand1.Par
'
'DataSet11
'
Me.DataSet11.DataSetName = "DataSet1"
Me.DataSet11.Locale = New System.Globalization.Cultu
CType(Me.DataSet11, System.ComponentModel.ISup
End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.
Protected WithEvents OleDbDataAdapter1 As System.Data.OleDb.OleDbDat
Protected WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCom
Protected WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCom
Protected WithEvents OleDbUpdateCommand1 As System.Data.OleDb.OleDbCom
Protected WithEvents OleDbDeleteCommand1 As System.Data.OleDb.OleDbCom
Protected WithEvents OleDbConnection1 As System.Data.OleDb.OleDbCon
Protected WithEvents DataSet11 As Practice2.DataSet1
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
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
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataGrid1.DataMember = "tblAlumni_pref"
DataGrid1.DataSource = DataSet11
OleDbDataAdapter1.Fill(Dat
DataGrid1.DataBind()
End Sub
Private Sub OleDbDataAdapter1_RowUpdat
End Sub
Private Sub OleDbConnection1_InfoMessa
End Sub
End Class
Oh, this looks a mess--were you using one of those code editors? It looks like you have way too many repetitions and that may be locking up Access on you!
FtB
FtB
ASKER
A lock file does keep appearing. I just made the page in visual studio and dragged and dropped one button, an oledbConnection, oledbDataAdapter. DataSet and DataGrid and only added the following code by hand, all the rest appeared automatically.
At the top of the code:
Imports System.Data.OleDb
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataGrid1.DataMember = "tblAlumni_pref"
DataGrid1.DataSource = DataSet11
OleDbDataAdapter1.Fill(Dat aSet11)
DataGrid1.DataBind()
End Sub
At the top of the code:
Imports System.Data.OleDb
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataGrid1.DataMember = "tblAlumni_pref"
DataGrid1.DataSource = DataSet11
OleDbDataAdapter1.Fill(Dat
DataGrid1.DataBind()
End Sub
ASKER
The error appears on the following line:
OleDbDataAdapter1.Fill(Dat aSet11)
OleDbDataAdapter1.Fill(Dat
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help.
Glad to have helped.
At least we know now that you can connect to Access, that all of your permissions are in place and etc. The next task will be to figure out why your code generator spits out so many duplicates!
FtB
At least we know now that you can connect to Access, that all of your permissions are in place and etc. The next task will be to figure out why your code generator spits out so many duplicates!
FtB
FtB