473,385 Members | 1,707 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,385 software developers and data experts.

ExecuteReader: Connection property has not been initialized

Hello, I'm using a combobox in vb 2010 and I got this code and i'm getting an error on my connection. Could someone please tell me why am i getting this kind of error and how to fix it?
Thank you.


Expand|Select|Wrap|Line Numbers
  1. Private Sub cbPlayer9_DropDown(sender As Object, e As System.EventArgs) Handles cbPlayer9.DropDown
  2.         Dim con As New SqlClient.SqlConnection
  3.         con.ConnectionString = My.Settings.MyConnectionString
  4.         Dim Query As String = "SELECT Nickname FROM Player WHERE Nickname not like '" & cbPlayer0.Text & "' AND Nickname not like '" & cbPlayer1.Text & "' AND Nickname not like '" & cbPlayer3.Text & "' AND Nickname not like '" & cbPlayer4.Text & "' AND Nickname not like '" & cbPlayer5.Text & "' AND Nickname not like '" & cbPlayer6.Text & "' AND Nickname not like '" & cbPlayer7.Text & "' AND Nickname not like '" & cbPlayer8.Text & "' AND Nickname not like '" & cbPlayer2.Text & "'"
  5.         Dim cmdselect As New SqlCommand
  6.         Dim ds As New DataSet()
  7.         Dim dt As DataTable
  8.         Dim read As SqlDataReader
  9.  
  10.         con.Open()
  11.         read = cmdselect.ExecuteReader()
  12.  
  13.         dt = New DataTable("Player")
  14.         ds.Tables.Add(dt)
  15.         ds.Load(read, LoadOption.PreserveChanges, ds.Tables(0))
  16.  
  17.         cbPlayer9.DataSource = ds.Tables(0)
  18.         con.Close()
  19.     End Sub
  20.  
Mar 3 '12 #1
3 2078
Problem Solved, no need to reply :)
Mar 3 '12 #2
Hi Mr.11Mercenary,

If u solved the issue,can u please post the solution. It ll be useful for others who all are searching to solve it:)
Thank you!
Apr 26 '12 #3
Sorry BeHappy but I solved it in a completely different way.
I changed all the appearance and the tools i was using.
Still want the code?
Apr 26 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
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...
2
by: CJM | last post by:
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...
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...
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: nada111 | last post by:
SelectCommand.Connection property has not been initialized
0
by: santiago8000 | last post by:
hello,i'm new to vb.net,and i'm trying to do my first program for my training...my program is about the Northwind2 database in sql server,i have a "ShowAll" button,that displays in a form the...
1
by: mamtaid | last post by:
i have the following code.... it gives the error::ExecuteReader: Connection property has not been initialized can anyone please help me sst = new DataSet(); asq = new...
1
by: abhi thakur | last post by:
Hi! I am experiencing a problem when trying to connect to my database. I keep getting an exception with the following error message: ExecuteReader: Connection property has not been initial ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.