Sunday, February 19, 2012

A problem to connect to sql server 2000

The sql server 2000 is runing at network pc named: pc1;
The ado.net is used to access the server with OLE DB .net
data provider.
The error at the OleDbError is
Message: SQL Server does not exist or access denied
NativeError: 17,
SQLState: 08001
Below is potion of the code (in C#):
OleDbConnection connection = null;
string cnString = @."Provider=SQLOLEDB; Data Source=\\pc1;"
+ "Initial Catalog = BOM; User ID = pyoung;
Password=pyoung";
try
{
connection = OleDbConnection(cnString);
connection.Open();
}
catch
{
for (int i=0; i < myException.Errors.Count; i++)
{
this.mStatusMsg = "Message: " + myException.Errors
[i].Message + "\\n" +
"Native: " + myException.Errors
[i].NativeError.ToString() + "\\n" +
"Source: " + myException.Errors[i].Source + "\\n" +
"SQL: " + myException.Errors[i].SQLState + "\\n";
}
connection.Close();
}
Where BOM is the database to use.
What did I miss to connect to the server correctly?
Thanks.
Pat
Data Source in your string is wrong.
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=useridHere;Data
Source=ServerNameHere
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.
|||You are right. So the Data Source is only the name
instead the path.
Thank you very much.
Pat
>--Original Message--
>Data Source in your string is wrong.
>Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=useridHere;Data
>Source=ServerNameHere
>
>Thanks,
>Kevin McDonnell
>Microsoft Corporation
>This posting is provided AS IS with no warranties, and
confers no rights.
>
>.
>
|||You're welcome!
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.

No comments:

Post a Comment