views:

54

answers:

3

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?

A: 

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

David M
+2  A: 

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>
peacmaker
beated me to it :)
Madi D.
A: 

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.

Joe Internet