473,480 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Connection Property error

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.

Nov 20 '05 #1
9 1419
Hello T.
You need to assign the ConnectionString property of your
command cmdStores.

Kind Regards
Jorge
-----Original Message-----
ExecuteReader: Connection property has not been initialized.
Description: An unhandled exception occurred during the execution of thecurrent web request. Please review the stack trace for more informationabout 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.

.

Nov 20 '05 #2
Jorge,

I think I did that. In the Form view, 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

You said the Connection String. I am looking at the Connection Property.

Where is the Connection String Property of the cmdStores located?
Will please give me a step-by-step?

Thanks,

T.

"Jorge" <an*******@discussions.microsoft.com> wrote in message
news:f0****************************@phx.gbl...
Hello T.
You need to assign the ConnectionString property of your
command cmdStores.

Kind Regards
Jorge
-----Original Message-----
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.

.

Nov 20 '05 #3

P.S. Just my opinion, if your using the objects from the data tab of
the toolbox... Stop!!!!!! Learn to do it, totally in code, no objects.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4
Are you using the objects from the data tab on the toolbox. ?

If you are... Did you set the properties via the property manager...
Look under 'Web Form Designer Generated Code' section of your
code-behind.

From your code, your not settng your connection string, unless you've
set it via the property manager of the sqlconnection object.

One other thing, Why are you executing a sqlreader, binding it to a
datasource then closing the sqlreader.
If your wanting to use a disconnected datasource, use a datatable or
dataset, and close the connection, not the source of your data.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5
I'm having hard time understanding the terminology. I don't know coding.
Please use examples.

OK. I set the CONNECTION STRING via the Properties Manager(i'm calling it
just Properties). The steps:
Properties of conPubs
click the +DynamicProperties
click the ConnectionString ... (3 dots)

Properties of cmdStores
cmdStores (added from the Data/Toolbox)
click the +Connection(not the plus sign but the drop down box)
selected conPubs

Will you please give me examples from my code?
What is my datasource?

Why is my program still showing the same error?

Thanks in advance for the help,
T.

"Terry Williams" <tl**********@aol.com> wrote in message
news:eP**************@tk2msftngp13.phx.gbl...

P.S. Just my opinion, if your using the objects from the data tab of
the toolbox... Stop!!!!!! Learn to do it, totally in code, no objects.
I'll stop when I'm more experienced. Or someone shows me how.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #6
I'm proberly not the right person to be teaching over the internet, and
it would take forever for me to try. Not that I don't want to, but one
of us, would be pulling our hair out soon.

But I understand what level your at now.

Most books always teach database programming from the standpoint of
using the objects in the toolbox. I'm totally against it.

I started programming using a language called Databus on Datapoint
systems. It's now called PL/B. There was no visual development
environment (laugh), just a good old text editor.

Is there anyone that could suggest a book for Taishi, that leans more
toward a pure coding standpoint.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7
It's just a 15 line program that I can not get to work.

It want take that long. Maby 1 to 2 responses.

Reading a book is different from receiving quality tips from a professional.

Taishi

"Terry Williams" <tl**********@aol.com> wrote in message
news:uv**************@TK2MSFTNGP11.phx.gbl...
I'm proberly not the right person to be teaching over the internet, and
it would take forever for me to try. Not that I don't want to, but one
of us, would be pulling our hair out soon.

But I understand what level your at now.

Most books always teach database programming from the standpoint of
using the objects in the toolbox. I'm totally against it.

I started programming using a language called Databus on Datapoint
systems. It's now called PL/B. There was no visual development
environment (laugh), just a good old text editor.

Is there anyone that could suggest a book for Taishi, that leans more
toward a pure coding standpoint.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #8

What's your connection string ?

Type type of component is ddlStores ? Just so I know..

It a combobox/Dropdownlist, which I assume it is.

Here is some of my Code as a demonstration using a dropdownlist. It
works, tested it out. Again DropDownList1 is a dropdownlist :) Fill in
the connectionstring and commandstring with your values and you are
ready to go.
If (Not IsPostBack) Then
Dim myDataReader As SqlClient.SqlDataReader
Dim MyConnection As New
SqlClient.SqlConnection("server=127.0.0.1;UID=sa;P WD=symantec;database=t
erryw6_jobs")
Dim MyCommand As New SqlClient.SqlCommand("Select DeptID
from Departments", MyConnection)
MyConnection.Open()

myDataReader = MyCommand.ExecuteReader

DropDownList1.DataSource = myDataReader
DropDownList1.DataTextField = "DeptID"
DropDownList1.DataValueField = "DeptID"
DropDownList1.DataBind()

MyConnection.Close()

End If

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #9
Terry,

Thanks for tutoring me. The hair pulling is gonna come from me not knowing
code. Trying to convert your code into the FORM Design.

My problem is sort of fixed. I did not close my MyConnection.

Now, I just have a blank list box. awuugghhh.. banging my head.

In the Properties for MyConnection I have the following as my Connection
String:

workstation id=MyMachineName;packet size=4096;integrated security=SSPI;data
source="MyMachineName\vsdotnet";attachdbfilename=" D:\Program Files\Microsoft
SQL Server\MSSQL$NETSDK\Data\pubs.mdf";persist security info=False;initial
catalog=pubs

In the Properties for MyCommand I have the following as my Connection
String:

workstation id=MyMachineName;packet size=4096;integrated security=SSPI;data
source="MyMachineName\vsdotnet";attachdbfilename=" D:\Program Files\Microsoft
SQL Server\MSSQL$NETSDK\Data\pubs.mdf";persist security info=False;initial
catalog=pubs

I'm trying to grasp the concept but it's frustrating.

Thanks,
T.

"Terry Williams" <tl**********@aol.com> wrote in message
news:#Y**************@TK2MSFTNGP10.phx.gbl...

What's your connection string ?

Type type of component is ddlStores ? Just so I know..

It a combobox/Dropdownlist, which I assume it is.

Here is some of my Code as a demonstration using a dropdownlist. It
works, tested it out. Again DropDownList1 is a dropdownlist :) Fill in
the connectionstring and commandstring with your values and you are
ready to go.
If (Not IsPostBack) Then
Dim myDataReader As SqlClient.SqlDataReader
Dim MyConnection As New
SqlClient.SqlConnection("server=127.0.0.1;UID=sa;P WD=symantec;database=t
erryw6_jobs")
Dim MyCommand As New SqlClient.SqlCommand("Select DeptID
from Departments", MyConnection)
MyConnection.Open()

myDataReader = MyCommand.ExecuteReader

DropDownList1.DataSource = myDataReader
DropDownList1.DataTextField = "DeptID"
DropDownList1.DataValueField = "DeptID"
DropDownList1.DataBind()

MyConnection.Close()

End If

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6749
by: James | last post by:
We've had a recurring problem where all of a sudden we get a DBMSSOCN General Network Error on any page that connects to SQL Server. Then we have to reboot the server and everything works fine...
3
55643
by: kant | last post by:
stringA= "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;PWD=password;Initial Catalog=DB;Data Source=127.0.0.1;Connect Timeout=30" stringB = "Provider=Microsoft.Jet.OLEDB.4.0; Data...
2
1239
by: Taishi | last post by:
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...
4
3508
by: Anthony England | last post by:
This is a simple question, which has been debated before, but can I ask it again with reference to a specific example? The question is basically should I close and set to nothing an ADO connection...
4
11480
by: maneeshjp | last post by:
Hi to all, I have wrote a jsp-servlet program(using struts) which connects to DB2 via JDBC. I am using Tomcat5.5. JDBC driver as400thinjdbc.jar . DB connection paramaters are <data-sources>...
0
1522
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
2
2434
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
0
1959
by: Robert Avery | last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and displayed for the user all connection events, so that I could easily see what SQL was taking a long time, and when it freezes, I...
0
6915
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7054
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6750
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3003
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2993
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
567
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.