Jump to content

Accessing SQL DB's


Guest catalyst

Recommended Posts

Guest catalyst

I have used an example off this site, and I have saved it as default.aspx, I the saved it in the directory of my database file which is northwnd.mdf, however when I run this file I get the error "file already in use"Can someone please help meThanksTim<%@ Import Namespace="System.Data.OleDb" %><script runat="server">sub Page_Loaddim dbconn,sql,dbcomm,dbreaddbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("/db/northwnd.mdf"))dbconn.Open()sql="SELECT * FROM customers"dbcomm=New OleDbCommand(sql,dbconn)dbread=dbcomm.ExecuteReader()customers.DataSource=dbreadcustomers.DataBind()dbread.Close()dbconn.Close()end sub</script><html><body><form runat="server"><asp:Repeater id="customers" runat="server"><HeaderTemplate><table border="1" width="100%"><tr bgcolor="#b0c4de"><th>Companyname</th><th>Contactname</th><th>Address</th><th>City</th></tr></HeaderTemplate><ItemTemplate><tr bgcolor="#f0f0f0"><td><%#Container.DataItem("companyname")%> </td><td><%#Container.DataItem("contactname")%> </td><td><%#Container.DataItem("address")%> </td><td><%#Container.DataItem("city")%> </td></tr></ItemTemplate><FooterTemplate></table></FooterTemplate></asp:Repeater></form></body></html>

Link to comment
Share on other sites

CauseThis error usually happens on Windows NT, Windows 2000 or Windows XP and may be caused by any of the following conditions:- the database file or database folder doesn?t have necessary security permissions to write to, or erase an .ldb file created by Microsoft Access when opening the database- the database file doesn't have sufficient security permissions or write permissions to be modified when updating data in it. The web browser is seen by the web server as a Internet User that has the server account IUSR. This user needs to have write permission to the database file and to the database folder. ResolutionFollow these steps to resolve this issue:1. Use Windows Explorer to find the folder on the disk, which contains the database file (.mdb). This is usually your project folder.2. Right-click on the project folder and select Properties.3. Uncheck the Read-only property.4. Click on the Security tab in the properties window.(Attention: If you don't see such tab (Windows XP), close the properties window, open any folder, select Tools -> Folder Options -> View, and uncheck the option Use simple file sharing.)5. Click Add and find, then select the user IUSR_<COMPUTERNAME>.6. Select the Write checkbox in the Allow; column to assign Write permissions to the IUSR account. Hope this helpsJustin

Link to comment
Share on other sites

  • 5 months later...
Guest likemoment

I grant permission for 'Network Service' to make it work.I used same sample code as Tim did, and the db was uploaded to a shared web hosting server. It seems iusr has nothing to do with it in my case.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...