views:

26

answers:

1

hi im trying to get a dataset from an access database

im using this connection string:

<connectionStrings>
    <add name="SiteConnString" connectionString="Data Source=c:\inetpub\vhosts\db\mainDB.mdb" 
         providerName="Microsoft.Jet.OLEDB.4.0" />
</connectionStrings>

and this is my call to SqlHelper:

myDataSet = SqlHelper.ExecuteDataset(connString, CommandType.Text, strSQL);

and the error im getting is this:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

+1  A: 

The providerName attribute expects an ADO.NET provider class name. Try changing your connection like so:

<connectionStrings>
    <add name="SiteConnString"
         connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\vhosts\db\mainDB.mdb"
         providerName="System.Data.OleDb" />
</connectionStrings>

A very handy reference for connection string formats is http://connectionstrings.com

kbrimington
i tried that allready actualy but this is the error i get with this connection string Exception Details: System.ArgumentException: Keyword not supported: 'provider'.
guy schaller
@guy - In this case, `SqlHelper` must be a class designed to support only SQL Server, for which "Provider" is indeed inappropriate in the connection string. You may get better mileage out of the System.Data.OleDb classes, especially its data adapter. Here is a link to relevant documentation and examples: http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbdataadapter%28VS.71%29.aspx
kbrimington
oh... ok now i get it. thank you very much!
guy schaller