Access using asp.net and password

Discussion in 'Databases' started by needrepairn, Dec 1, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am using an asp.net page to display data from Access database. Works if not password protected, but when I add a password to the database, then upload and change my asp.net code by adding ;password=thepassword; I get the following error:

    Server Error in '/' Application.

    Cannot start your application. The workgroup information file is missing or opened exclusively by another user.

    Following is query.aspx file:

    <%@ Page Language="VB" Debug="true" %>
    <%@ Import namespace="System.Data" %>
    <%@ Import namespace="System.Data.OleDb" %>

    <html>
    <head>
    <title>Connecting to Access Database</title>
    </head>



    <H3>Connecting to an Access Database</H3>
    <asp:Datagrid id="dgSuppliers" runat="server" />
    </body>

    </html>

    <script language="VB" runat="server">

    Sub Page_Load(Source As Object, E as EventArgs)
    Dim strConnection As String = "Provider=Microsoft.Jet.Oledb.4.0;data source=E:\web\needrepairn\htdocs\blank.mdb;password=mytele;"

    Dim objConnection as New OleDbConnection(strConnection)

    Dim strSQL as string = "Select * from bills"

    dim objCommand as New OleDbCommand(strSQL, objConnection)
    <%--server.mappath --%>
    objConnection.Open()
    dgSuppliers.Datasource = objCommand.ExecuteReader()
    dgSuppliers.DataBind()
    objConnection.Close()
    End Sub
    </script>
     
  2. I added ;User Id=admin; and get the same error. It does work with asp code without supplying a user id. I know the password is correctly database protected as I must supply the password when I use the ASP code. You can check it out at www.needrepair.net/query.asp.

    try sql of select * from clients; pwd is mytele
     
  3. that would be database is correctly password protected.
     
  4. This works after change to source= line:
    http://beta.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20663455.html

    <%@ Page Language="VB" Debug="true" %>
    <%@ Import namespace="System.Data" %>
    <%@ Import namespace="System.Data.OleDb" %>

    <html>
    <head>
    <title>Connecting to Access Database</title>
    </head>



    <H3>Connecting to an Access Database</H3>
    <asp:Datagrid id="dgSuppliers" runat="server" />
    </body>

    </html>

    <script language="VB" runat="server">

    Sub Page_Load(Source As Object, E as EventArgs)
    Dim strConnection As String = "Provider=Microsoft.Jet.Oledb.4.0;data

    source=E:\web\needrepairn\htdocs\blank.mdb;User Id=admin;Jet OLEDB:Database Password=mytele;"

    Dim objConnection as New OleDbConnection(strConnection)

    Dim strSQL as string = "Select * from clients"

    dim objCommand as New OleDbCommand(strSQL, objConnection)
    <%--server.mappath --%>
    objConnection.Open()
    dgSuppliers.Datasource = objCommand.ExecuteReader()
    dgSuppliers.DataBind()
    objConnection.Close()
    End Sub
    </script>
     
  5. Bruce

    Bruce DiscountASP.NET Staff

    Did you password protect your database?

    You can do that in MS Access

    - Tools -> Security -> Set database password

    In addition, you'll need to specify the useraccount, default is admin

    Add this to your connection string

    User Id=admin

    quote:Originally posted by needrepairn

    I am using an asp.net page to display data from Access database. Works if not password protected, but when I add a password to the database, then upload and change my asp.net code by adding ;password=thepassword; I get the following error:

    Server Error in '/' Application.

    Cannot start your application. The workgroup information file is missing or opened exclusively by another user.

    Following is query.aspx file:

    <%@ Page Language="VB" Debug="true" %>
    <%@ Import namespace="System.Data" %>
    <%@ Import namespace="System.Data.OleDb" %>

    <html>
    <head>
    <title>Connecting to Access Database</title>
    </head>



    <H3>Connecting to an Access Database</H3>
    <asp:Datagrid id="dgSuppliers" runat="server" />
    </body>

    </html>

    <script language="VB" runat="server">

    Sub Page_Load(Source As Object, E as EventArgs)
    Dim strConnection As String = "Provider=Microsoft.Jet.Oledb.4.0;data source=E:\web\needrepairn\htdocs\blank.mdb;password=mytele;"

    Dim objConnection as New OleDbConnection(strConnection)

    Dim strSQL as string = "Select * from bills"

    dim objCommand as New OleDbCommand(strSQL, objConnection)
    <%--server.mappath --%>
    objConnection.Open()
    dgSuppliers.Datasource = objCommand.ExecuteReader()
    dgSuppliers.DataBind()
    objConnection.Close()
    End Sub
    </script>
    </blockquote id="quote"></font id="quote">
     
  6. In the asp.net code it is not possible. In the asp code, it is possible to delete records by providing a sql statement.
     
  7. quote:Originally posted by needrepairn

    I added ;User Id=admin; and get the same error. It does work with asp code without supplying a user id. I know the password is correctly database protected as I must supply the password when I use the ASP code. You can check it out at www.needrepair.net/query.asp.

    try sql of select * from clients; pwd is mytele
    </blockquote id="quote"></font id="quote">

    I hope this is only a demo-database ... otherwise everybody could now delete all your records ...
    If not, change your password as quick as possible !

    --
    Steurm
    www.steurm.net/steurm
     
  8. The name of my database is blank.mdb, so no, it is not production. Also, I have actually deleted it, changed the password and haven't uploaded it again, yet, so it won't work anymore. I hope having the working code posted here is helpful to some to jumpstart their learning or not have to go through the troubleshooting and research that I did. I think I tried the change before from password= to Jet OLEDB:Database Password= and still got an error, so perhaps adding the user id= is also necessary.
     
  9. Bruce

    Bruce DiscountASP.NET Staff

    This is not possible.

    Unlike many other hosting companies (1 user for the whole server), we run each website using unique credential. Other websites do not have permission to even open the database.



    quote:Originally posted by steurm

    quote:Originally posted by needrepairn

    I added ;User Id=admin; and get the same error. It does work with asp code without supplying a user id. I know the password is correctly database protected as I must supply the password when I use the ASP code. You can check it out at www.needrepair.net/query.asp.

    try sql of select * from clients; pwd is mytele
    </blockquote id="quote"></font id="quote">

    I hope this is only a demo-database ... otherwise everybody could now delete all your records ...
    If not, change your password as quick as possible !

    --
    Steurm
    www.steurm.net/steurm
    </blockquote id="quote"></font id="quote">
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page