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

sqldatareader problem

I keep getting this error :
"System.Data.SqlClient.SqlException: Line 1: Incorrect
syntax near 'Name'."

Heres the code :
Sub BindData()
Dim sql As String = "Select Clientid,Client Name
from register order by Client Name"
Dim Cmd As New SqlCommand(sql, myConn)
Dim objDR As SqlDataReader
myConn.Open()
objDR = Cmd.ExecuteReader
(System.Data.CommandBehavior.CloseConnection)
Me.cboClient.DataSource = objDR
Me.cboClient.DataValueField = "EmployeeID"
Me.cboClient.DataTextField = "LastName"
Me.cboClient.DataBind()
Me.cboClient.SelectedIndex = 0
myConn.Close()
End Sub

Anyone help ?
Nov 17 '05 #1
2 929
Your SQL Select string should look like:

"Select Clientid,[Client Name] from register order by [Client Name]"

Generally it's not a good idea to have column names with spaces in it.

Hope that helps.

Cheers,
Wim Hollebrandse
http://www.wimdows.net
http://www.wimdows.com
---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
Nov 17 '05 #2
Your SQL Select string should look like:

"Select Clientid,[Client Name] from register order by [Client Name]"

Generally it's not a good idea to have column names with spaces in it.

Hope that helps.

Cheers,
Wim Hollebrandse
http://www.wimdows.net
http://www.wimdows.com
---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
Nov 17 '05 #3

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

Similar topics

3
by: Ricola ! | last post by:
Why do I say: SqlDataReader dr; instead of SqlDataReader dr = new SqlDataReader();
2
by: Matthias S. | last post by:
Hi, I've written a simple app which should just fetch some data from a database and render the results into a ListView. In order to not freeze the GUI, I'm using a BackgroundWorker. The...
7
by: Franck Diastein | last post by:
Hi, when I call ExportData I have this error: Invalid attempt to Read when reader is closed. Telling me that there's a problem with this line: while(_dataR.Read()){ Code:...
3
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the...
1
by: Arvind P Rangan | last post by:
Hi All, How do you get all the values of a sqldatareader if it contains multiple resultset. Using sqldatareader.nextresult and sqldatareader.read e.g. While sqldatareader.read ' If not...
8
by: bidllc | last post by:
I have a funtion that works fine and dandy when called from anywhere in my app. It will NOT work when called from inside the class in which it resides. This is the function I'm calling:...
4
by: mimi | last post by:
Hi Please help me out, I can't find a way to close a sqldatareader when error occur at statement cmd.ExecuteReader(). I can't close it in catch because it is local in try scope and I can't...
4
by: Agnes | last post by:
I got two sub method to check some history record, Now, I found that there is some problem in Sub2() . I think the problem is about the myReader. However, I got no idea to solve it . As Sub2()...
7
by: Web learner | last post by:
I am trying to create a method GetDataFor(string column) becaues I have to repeat the same statements for several columns but I get an error as follows: The name 'dr' does not exist in the current...
3
by: yogarajan | last post by:
hi i am using two sqldatareader. that gives error My code start here SqlConnection conn = new SqlConnection("Data Source=**********;Initial Catalog=****; User Id=****; Password=******"); ...
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: 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:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.