473,287 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

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 1414
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
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
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
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
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
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
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
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
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.