Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Connection Property not initializing

0 views
Skip to first unread message

Taishi

unread,
Feb 11, 2004, 4:40:42 PM2/11/04
to
VB.NET
VS.NET
Web Form

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


Any ideas as to why am receiving the error below?

Thanks,

T.

"Suresh" <anon...@discussions.microsoft.com> wrote in message
news:69814EAE-5550-4CDA...@microsoft.com...
> 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
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.


0 new messages