Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ExecuteReader: Connection Property has not been initialized

Status
Not open for further replies.

BiniamTek

IS-IT--Management
May 16, 2003
22
0
0
US
Hello,

I receive the above error for my line:
dr = currentSqlCommand.ExecuteReader();

How do I initialize the connection property?

Thanks.
 
First of all commands come in different flavours in .net.
But I would think every command needs an active connection.
You can set the connection in the constructor or use the .connection property of the command to set it later.

If you are using vs 2002/2003 than you can check out the constructors like so:
dim com as New SqlCommand(
After typing the ( you get the parameter(s) that can be passed to the constructor, when you use up and down arrow of your keyboard you can see the overloaded constructors.
here are the constructors for a sqlcommand:

Dim commm As New SqlCommand(commandText)
Dim commm As New SqlCommand(commandText, connection)
Dim commm As New SqlCommand(commandText, connection, transaction)
Dim commm As New SqlCommand()




Greetings, Harm Meijer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top