SqlDataReader

  • Thread starter Thread starter Rodrigo
  • Start date Start date
R

Rodrigo

Dears,

is have a logon routine that I can use it only once. At the second time,
when the line code is executed, the following message is sent:

Dim Reader As SqlDataReader =
qHospede.ExecuteReader(CommandBehavior.CloseConnection)


At the second time this message is sent:


"There is already an open DataReader associated with this Connection which
must be closed first"

Where is my mistake?

Thanks for any help.

Rodrigo.
 
Rodrigo,

You need to close the DataReader before you are able to use it again. The flag "CommandBehavior.CloseConnection" will tell the DataReader to close its connection upon
close the DataReader. So you should call Reader.Close() before you leave or execute the code again.


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
 
Try explicity closing the SqlDataReader object.
Dim Reader As SqlDataReader =
qHospede.ExecuteReader(CommandBehavior.CloseConnection)
Reader.Close()
 
THANKS HUSSEIN AND MICHAEL.

IT WORKS....

RODRIGO.


Hussein Abuthuraya said:
Rodrigo,

You need to close the DataReader before you are able to use it again. The
flag "CommandBehavior.CloseConnection" will tell the DataReader to close its
connection upon
close the DataReader. So you should call Reader.Close() before you leave or execute the code again.


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
 
Back
Top