Updating the old piece of software, but to maintain backward compatibility I need to connect to the .mdb (access) database.
I am using the following connection but keep getting an exception, why?
I checked the path, the existence of the database, etc., and that is all right.
string Server = "localhost";
string Database = drive + "\\btc2\\state\\states.mdb";
string Username = "";
string Password = "Lhotse";
string ConnectionString = "Data Source = " + Server + ";" +
"Initial Catalog = " + Database + ";" +
"User Id = '';" +
"Password = " + Password + ";";
SqlConnection SQLConnection = new SqlConnection();
try
{
SQLConnection.ConnectionString = ConnectionString;
SQLConnection.Open();
}
catch (Exception Ex)
{
if (SQLConnection != null)
SQLConnection.Dispose();
return false;
}
Exception Message:
When connecting to SQL Server, a network-related or specific instance error occurred. The server was not found or was not available. Verify the instance name is correct and configure SQL Server to connect remotely. (provider: Named Pipes provider, error: 40 - Could not open SQL Server connection)
source
share