TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
supermikey00
NA
2
0
ExecuteReader Error
Sep 24 2003 4:27 AM
I'm trying to learn how to execute a stored procedure in .net. I'm using a textbook example and yet the code gives me the following error when run: "An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll Additional information: ExecuteReader: Connection property has not been initialized." Here is the actual code. Can you tell me what the problem is? Thanks. Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged SqlConnection1.Open() SqlCommand1.CommandType = CommandType.StoredProcedure SqlCommand1.CommandText = "OrdersPerCustomer" If SqlCommand1.Parameters.Count = 0 Then SqlCommand1.Parameters.Add(New _ System.Data.SqlClient.SqlParameter("@CustomerID", SqlDbType.NChar)) SqlCommand1.Parameters(0).Direction = ParameterDirection.Input End If SqlCommand1.Parameters(0).Value = ListBox1.SelectedValue.ToString Dim SQLReader As System.Data.SqlClient.SqlDataReader SQLReader = SqlCommand1.ExecuteReader While SQLReader.Read txtOrders.Text = SQLReader.Item("Total Orders").ToString txtAmount.Text = SQLReader.Item("Total Amount").ToString End While SqlConnection1.Close() End Sub End Class
Reply
Answers (
0
)
Data storage without the use of a Database?
Dataset problem