473,472 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ExecuteReader: Connection property has not been initialized.

CJM
I'm not sure where I cam going wrong here... I'm getting the runtime error
above, but my code seems reasonable. Am I missing something?

Code Snippet:

oConn = New SqlConnection
oConn.ConnectionString = "Data Source=MyServer;Initial Catalog=TADB;User
Id=TADB;Password=xxx;"
oCmd = New SqlCommand("Exec TA_GetTADetails " & txtTANumber.Text)
oConn.Open()

dgResults.DataSource = oCmd.ExecuteReader()
<=========== error
dgResults.DataBind()

oConn.Close()

Thanks

Chris
Nov 18 '05 #1
2 14218
You aren't associating your command with your connection

oCmd = new SqlCommand("....", oConn) I believe

or after you create the command, you can do
oCmd.Connection = oConn (again, I think)

anyways, that's your problem.. and there are even more ways so solve
it...like:
oCmd = oConn.CreateCommant("EXEC...")

Karl

"CJM" <cj*******@newsgroups.nospam> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
I'm not sure where I cam going wrong here... I'm getting the runtime error
above, but my code seems reasonable. Am I missing something?

Code Snippet:

oConn = New SqlConnection
oConn.ConnectionString = "Data Source=MyServer;Initial Catalog=TADB;User Id=TADB;Password=xxx;"
oCmd = New SqlCommand("Exec TA_GetTADetails " & txtTANumber.Text)
oConn.Open()

dgResults.DataSource = oCmd.ExecuteReader()
<=========== error
dgResults.DataBind()

oConn.Close()

Thanks

Chris

Nov 18 '05 #2
CJM
Yeah, you are right... my bad.

Thanks

"Karl" <none> wrote in message news:ef*************@tk2msftngp13.phx.gbl...
You aren't associating your command with your connection

oCmd = new SqlCommand("....", oConn) I believe

or after you create the command, you can do
oCmd.Connection = oConn (again, I think)

anyways, that's your problem.. and there are even more ways so solve
it...like:
oCmd = oConn.CreateCommant("EXEC...")

Karl

Nov 18 '05 #3

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

Similar topics

2
by: MattB | last post by:
I'm trying to implement an example I found for displaying images stored in a SQL database. The example code looks like this (in page_load): Dim connstr As String = "Integrated...
3
by: Jason Williard | last post by:
I am trying to create a web form that will be used to create new users. The first step that I am taking is creating a web form that can check the username against a database to see if it already...
4
by: phil | last post by:
Hi, With the code below, i get the error: ExecuteReader: Connection property has not been initialized. Description: An unhandled exception occurred during the execution of the current web...
1
by: fniles | last post by:
I am using OLEDBDataReader to read from an Access database. I have 4 data source where I get my data from, and each data source is in its own thread. When receiving data, if it is a new...
7
by: Lawrence 007 | last post by:
Hi, I am new to VB.Net and I am trying to create a program that inserts data into a SQL table. Below you will find my code that gives me the following error: Connection Property has not been...
2
by: Martin Z | last post by:
I'm using the TableAdapterHelper to set the connection and transaction properties on all the commands of all my typed table adapters.... I've checked at the time of the error and all the commands...
7
by: fniles | last post by:
I am using VB.Net 2003 and MS Access (connecting using OleDBConnection). I read using DataAdapter and DataSet, not DataReader. When many people try to access the database at the same time, I get...
2
by: gggram2000 | last post by:
Hi, I'm using visual studio 2005 with sql server 2005. I made a program on my computer that works great. I wanted to transfer the same project through a remote connection to another computer, I...
2
by: murugavelmsc | last post by:
Hi, In Visual studio 2008, i got a error "ExecuteReader: Connection property has not been initialized" . So guide me protected void Button1_Click(object sender, EventArgs e) { ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.