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)

2
  • Just guessing, but you have connString and SiteConnString. Commented Aug 28, 2010 at 18:42
  • @Remou: One's a local or class variable, the other is a key to a config entry. Unfortunately, it probably isn't the problem here. Commented Aug 28, 2010 at 18:55

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

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 - 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: msdn.microsoft.com/en-us/library/…

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.