Connection Property error

T

Taishi

ExecuteReader: Connection property has not been initialized.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidOperation Exception: ExecuteReader:
Connection property has not been initialized.

Source Error:

Line 142:
Line 143: drStores = cmdStores.ExecuteReader()
Line 144: ddlStores.DataSource = drStores
Line 145: ddlStores.DataTextField = "stor_name"


Any suggestions on how to resolve this error?

Thanks,
T.
 
G

Guest

Make sure a connection object has been opened and assigned to your cmdStores object prior to executing this line drStores = cmdStores.ExecuteReader()

You should have something like the following(I'm assuming you are using SQLCommand

SqlConnection sqlCon = new SqlConnection(Your SQL Connection String)
sqlCon.Open()

cmdStores.Connection = sqlCon
...
...
drStores = cmdStores.ExecuteReader()

HTH
Suresh

----- Taishi wrote: ----

ExecuteReader: Connection property has not been initialized

Description: An unhandled exception occurred during the execution of th
current web request. Please review the stack trace for more informatio
about the error and where it originated in the code

Exception Details: System.InvalidOperation Exception: ExecuteReader
Connection property has not been initialized

Source Error

Line 142
Line 143: drStores = cmdStores.ExecuteReader(
Line 144: ddlStores.DataSource = drStore
Line 145: ddlStores.DataTextField = "stor_name


Any suggestions on how to resolve this error

Thanks
T
 
T

Taishi

Suresh,

VS.Net
VB.Net

I was in the Form view and I notice that the cmdStores Connection Property
was set to conPubs. After the program is ran, the Connection Property
changes back to none. Here is my code:

Dim drStores As SqlClient.SqlDataReader

If Not IsPostBack Then

conPubs.Open()

drStores = cmdStores.ExecuteReader()

ddlStores.DataSource = drStores

ddlStores.DataTextField = "stor_name"

ddlStores.DataBind()

drStores.Close()

End If

End Sub



Thanks,

T.

Suresh said:
Make sure a connection object has been opened and assigned to your
cmdStores object prior to executing this line drStores =
cmdStores.ExecuteReader().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top