Re: Classic ADO & .NET
From: Shock (no_at_way.com)
Date: 10/10/04
- Next message: Val Mazur: "Re: Error using JET_SCHEMA_USERROSTER"
- Previous message: Guy Cohen: "Re: Error language"
- In reply to: Jerry Pisk: "Re: Classic ADO & .NET"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 10 Oct 2004 13:47:08 -0500
Jerry Pisk wrote:
> You should pass the login and password either in the connection string or as
> parameters to Connection.Open() but not both.
>
> Jerry
>
> "Shock" <no@way.com> wrote in message
> news:10mgj6rm304g982@corp.supernews.com...
>
>>Hey guys,
>>
>>I'm trying to connect to an SQL Server Database using classic ado in
>>VS.Net using the C# lang. I am using the Microsoft ActiveX Data Objects
>>Library version 2.8. Here is the code I've written so far.
>>
>> public ADODB.Recordset getRecordSet(string strQuery)
>> {
>> ADODB.Connection adodbcon = new Connection();
>> int intOptions = ((int)ADODB.CommandTypeEnum.adCmdTable);
>> string conString = "Provider=SQLOLEDB;Initial
>>Catalog=cperkins;Data Source=(local)\\AgC;User ID=sa;";
>> string strUser = "sa";
>> string strPassword = string.Empty;
>> adodbcon.Open(conString, strUser, strPassword, intOptions);
>>
>> ADODB.Command adodbcom = new Command();
>> adodbcom.CommandText = strQuery;
>> adodbcom.CommandType = ADODB.CommandTypeEnum.adCmdText;
>>
>> ADODB.Recordset adodbrs = new ADODB.Recordset();
>> adodbrs.Open(adodbcon, adodbcom,
>>ADODB.CursorTypeEnum.adOpenDynamic,
>>ADODB.LockTypeEnum.adLockBatchOptimistic,
>>(int)ADODB.CommandTypeEnum.adCmdTable);
>>
>> return adodbrs;
>> }
>>
>>The I get this error, "Arguments are of the wrong type, are out of
>>acceptable range, or are in conflict with one another.", on the
>>adodbcon.open statement.
>>
>>I haven't used 'Classic ADO' in years so I wouldn't be surprised if I was
>>doing something completely asinine. Thanks ahead for any help.
>>
>>Shock
>
>
>
Just an update: I got it to work by declaring the User/Pass in the
connection string and passing nulls for those arguments in
connection.open(). Like so,
connection.open(conString, null, null, 0);
However, it's funny, it still won't work if I take the user/pass out of
the string and pass them in as arguments. Very strange, but I'm not too
worried about it. I will hard use classic ADO, so I'm just satisfied
with it working. Thanks for the help.
Shock
- Next message: Val Mazur: "Re: Error using JET_SCHEMA_USERROSTER"
- Previous message: Guy Cohen: "Re: Error language"
- In reply to: Jerry Pisk: "Re: Classic ADO & .NET"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|