Setting the ActiveConnection property of a Command Object (ADO 2.7) 
Author Message
 Setting the ActiveConnection property of a Command Object (ADO 2.7)

I used to use the syntax of MyCommand.ActiveConnection = cnnConnection where
cnnConnection is an open connection object to a database.  This no longer
seems to work in VB.NET.  I keep getting the error "Specified cast is not
valid." What am I doing wrong?


Fri, 17 Dec 2004 19:25:42 GMT  
 Setting the ActiveConnection property of a Command Object (ADO 2.7)
Don't know if this helps, but there are now different
types of ADO objects... for SQL and for OLEDB.  Could that
have anything to do with it?  I use an open SQLConnection
and dim a new SQLCommand, passing the CommandText and the
SQLConnection object into the constructor, and this works
fine.

Quote:
>-----Original Message-----
>I used to use the syntax of MyCommand.ActiveConnection =
cnnConnection where
>cnnConnection is an open connection object to a

database.  This no longer
Quote:
>seems to work in VB.NET.  I keep getting the

error "Specified cast is not
Quote:
>valid." What am I doing wrong?

>.



Fri, 17 Dec 2004 20:37:57 GMT  
 Setting the ActiveConnection property of a Command Object (ADO 2.7)
That should really work, Rebecca. i have used that under VB.NET. i used the
ADODB class.....and hence my code reads..

Dim cmdADO as New ADODB.Command()
cmdADO.ActiveConnection = cn

where cn is my connection object....of type ADODB.Connection.

HTH
--Venson


Quote:
> I used to use the syntax of MyCommand.ActiveConnection = cnnConnection
where
> cnnConnection is an open connection object to a database.  This no longer
> seems to work in VB.NET.  I keep getting the error "Specified cast is not
> valid." What am I doing wrong?



Sat, 18 Dec 2004 05:10:19 GMT  
 Setting the ActiveConnection property of a Command Object (ADO 2.7)

I used to use the syntax of MyCommand.ActiveConnection = cnnConnection where
cnnConnection is an open connection object to a database.  This no longer
seems to work in VB.NET.  I keep getting the error "Specified cast is not
valid." What am I doing wrong?

You might want to post your code so we can see how you are defining your objects. It sounds like you
might be mixing objects from different libraries.


Microsoft MVP (Visual Basic)



Sat, 18 Dec 2004 21:25:11 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Set {command object}.ActiveConnection = fails sporadically

2. Question Ado 2.7 Field Object , Vb6.0

3. Difference between .ActiveConnection and SET .ActiveConnection?

4. Set ADODB.Command.ActiveConnection = Conn

5. Problems setting ActiveConnection in ADODB.Command

6. Problems setting ActiveConnection in ADODB.Command

7. Datagrid with ADO 2.7

8. ADO 2.7 in VB.NET

9. ADO 2.7 recordset binding

10. ADO 2.7 in VB.NET

11. using ADO 2.7 on Windows 95 machine

12. ADO 2.7 in VB.NET

 

 
Powered by phpBB® Forum Software