1

I am using MS Access 2013 Database name is "comm" and Password is "xyz@12345"

Web.config Connection String :

<add name="commconn" connectionString="Provider=Microsoft.ACE.OLEDB.12.0; Data Source=E:/ee/comm.accdb; Jet OLEDB:Database Password=xyz@12345;" />

When i run my WebSite it gives an Error only where my DropDownList Bind Data and the Error is this "Not a valid password."

I bind my DropDownList using this code :

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AccessDataSource1" DataTextField="share_amt" DataValueField="ID">
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/comm.accdb" SelectCommand="SELECT * FROM [share_amt] ORDER BY [ID]">
</asp:AccessDataSource>

I am using MS Access 2013 Database and ASP.Net with C#.

1 Answer 1

5

It appears that the crux of your problem is:

  1. In Web.config you've created a data connection named commconn for a password-protected Access database named "comm.accdb", but
  2. You've tried to use an AccessDataSource to populate your DropDownList, and that AccessDataSource refers directly the Access database via the DataFile= argument; the commconn data connection has nothing to do with it.

Furthermore, the MSDN article

Retrieving Data Using the AccessDataSource Web Server Control

says:

Note

The AccessDataSource will not connect to an Access database that is password-protected; to retrieve data from a password-protected Access database, use the SqlDataSource control.

So, for a password-protected Access database named "comm.accdb" in your App_Data folder you would need a <connectionStrings> entry like this in Web.config:

<add name="commConnectionString" 
    connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\comm.accdb;Jet OLEDB:Database Password=xyz@12345"
    providerName="System.Data.OleDb" />

along with something like this on your .aspx page:

<asp:SqlDataSource 
    ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:commConnectionString %>" 
    ProviderName="<%$ ConnectionStrings:commConnectionString.ProviderName %>" 
    SelectCommand="SELECT * FROM [share_amt] ORDER BY [ID]">
</asp:SqlDataSource>
<asp:DropDownList ID="DropDownList1" runat="server" 
    DataSourceID="SqlDataSource1" DataTextField="share_amt" DataValueField="ID">
</asp:DropDownList>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.