P
Peter
Hi, everybody,
Error message is "COM object that has been separated from its underlying RCW
can not be used." When I called the codes below. So I traced the error and
found it is caused by "oCmd.Despose". BTW,these codes are included in a .net
component.
'-----------------------------------------------------------------
Dim odr As OleDbDataReader
Dim oCmd As New OleDbCommand
If Conn.State = ConnectionState.Closed Then Conn.Open()
With oCmd
.Connection = Conn
.CommandType = CommandType.StoredProcedure
.CommandText = "udpMySP"
.Parameters.Add(New OleDbParameter("", OleDbType.Integer))
.Parameters(0).Value = iID
End With
Try
odr = oCmd.ExecuteReader
Do While odr.Read()
'do something
Loop
Catch expOleDb As OleDbException
'handle error
Finally
If Conn.State <> ConnectionState.Closed Then Conn.Close()
oCmd.Dispose()
If Not odr.IsClosed Then odr.Close()
End Try
'------------------------------------------------------------------
Thanks in advance,
Peter
Error message is "COM object that has been separated from its underlying RCW
can not be used." When I called the codes below. So I traced the error and
found it is caused by "oCmd.Despose". BTW,these codes are included in a .net
component.
'-----------------------------------------------------------------
Dim odr As OleDbDataReader
Dim oCmd As New OleDbCommand
If Conn.State = ConnectionState.Closed Then Conn.Open()
With oCmd
.Connection = Conn
.CommandType = CommandType.StoredProcedure
.CommandText = "udpMySP"
.Parameters.Add(New OleDbParameter("", OleDbType.Integer))
.Parameters(0).Value = iID
End With
Try
odr = oCmd.ExecuteReader
Do While odr.Read()
'do something
Loop
Catch expOleDb As OleDbException
'handle error
Finally
If Conn.State <> ConnectionState.Closed Then Conn.Close()
oCmd.Dispose()
If Not odr.IsClosed Then odr.Close()
End Try
'------------------------------------------------------------------
Thanks in advance,
Peter