0

Hey, I don't really understand database connection strings so I'm having problems debugging it. Any help not only figuring out the problem but also what is going on would be really appreciated:

I have a website on my localhost and I'm trying to get a sqldatasource to populate my gridview but it gives me the error 'Data source name not found and no default driver specified'.

My page says:

<asp:gridview id="AllOrdersChart" runat="server" Width="100%" DataSourceID="SqlDataSource1">
</asp:gridview>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:lollipopDB %>"
ProviderName = "System.Data.Odbc"
SelectCommand="SELECT * FROM LollipopsDB"></asp:SqlDataSource>

and my web.config says:

<connectionStrings>
    <add name="lollipopDB" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\inetpub\wwwroot\Lollipops\App_Data\lollipopsDB.mdb;"
        providerName="System.Data.OleDb" />
</connectionStrings>

Ideas on what is wrong?

3 Answers 3

2

as you use an sql datasource you have to change your provider name

<asp:AccessDataSource ConnectionString="<%$ ConnectionStrings:lollipopDB %>"
 ProviderName = "System.Data.OleDb"
 SelectCommand="SELECT * FROM LollipopsDB"> </asp:AccessDataSource>

instead

<asp:SqlDataSource>  </asp:SqlDataSource>
Sign up to request clarification or add additional context in comments.

Comments

0

Your provider names don't match, for starters. Try using System.Data.OleDb for both.

Comments

0

Have you already created the DSN (data source name) on the system? If not, you'll need to do so under administrative tools in the Windows control panel, before you can access it.

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.