"Unknown ProviderConnection string is not valid" exception

T

Tory Eneboe

Hi,

I'm trying to open a connection to a SQL Server DB in C# (so that I can
later execute a stored procedure). The code I have included below produces
the following exception when "connection.Open()" is executed:
Unknown ProviderConnection string is not valid

In reading some of the other postings, it sounded like I should not have to
specify a "Provider" if accessing a SQL Server DB using ADO??? Does anyone
know how to fix this problem? I have launched Query Analyzer and verified
that the server, uid, pwd, and database are indeed correct. Also, I change
the SqlConnection string to point to a DB local to my development machine,
and it then worked fine.

By the way, I am using Widbey. However, our group does have (pre-Widbey) C#
code that is identical to the code show below, and that accesses the exact
same DB. That code works fine.

I'm not sure where to go from here, so any ideas would be appreciated.
Tory.

try
{
SqlConnection connection = new SqlConnection
("server=myserver.intel.com;uid=tory;pwd=example;database=Test");
connection.Open();
}
finally
{
if (connection.State == ConnectionState.Open)
connection.Close();
}
 
M

Marina

If you are using the SqlConnection class (which I suspect you are), then you
are correct, you need to leave the Provider keyword out, as it is not
supported (and unnecessary - classes in System.Data.SqlClient only support
SQL Server in the first place). If you were connecting to it via
OleDbConnection, then you would need it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top