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

Line 1: Incorrect syntax near '1'.

I just use DataSet to bind DataSetGrid and display from SQL DB.
when starting run in Visual Studio 2005, get "Line 1: Incorrect syntax near
'1'" error message from below fill line,

objDataAdapter.Fill(objDataSet, "mindata")
any help is greatly appriciated.
Jun 22 '06 #1
6 2961
The error refers to a syntax error in the SQL query you are using to get
the data. What does the SQL query look like?

martin1 wrote:
I just use DataSet to bind DataSetGrid and display from SQL DB.
when starting run in Visual Studio 2005, get "Line 1: Incorrect syntax near
'1'" error message from below fill line,

objDataAdapter.Fill(objDataSet, "mindata")
any help is greatly appriciated.

Jun 22 '06 #2
it is

objDataAdapter.SelectCommand.CommandText = _
"Select Parameter, Average, Units from mindata"

Thanks

"Göran Andersson" wrote:
The error refers to a syntax error in the SQL query you are using to get
the data. What does the SQL query look like?

martin1 wrote:
I just use DataSet to bind DataSetGrid and display from SQL DB.
when starting run in Visual Studio 2005, get "Line 1: Incorrect syntax near
'1'" error message from below fill line,

objDataAdapter.Fill(objDataSet, "mindata")
any help is greatly appriciated.

Jun 22 '06 #3
the whole program is :

Imports System.Data
Imports System.Data.SqlClient
Public Class GreeneCTControlRoom
Dim objConnection As New SqlConnection _
("Server=server1; database=db1;user id=sa;password=whatever")
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As New DataSet()
Private Sub GreeneCTControlRoom_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = _
"Select Parameter, Average, Units from mindata"
objDataAdapter.SelectCommand.CommandText = CommandType.Text

objConnection.Open()
objDataAdapter.Fill(objDataSet, "mindata")
objConnection.Close()

grdControlRoom.AutoGenerateColumns = True
grdControlRoom.DataSource = objDataSet
grdControlRoom.DataMember = "mindata"

objDataAdapter = Nothing
objConnection = Nothing

End Sub
End Class
"Göran Andersson" wrote:
The error refers to a syntax error in the SQL query you are using to get
the data. What does the SQL query look like?

martin1 wrote:
I just use DataSet to bind DataSetGrid and display from SQL DB.
when starting run in Visual Studio 2005, get "Line 1: Incorrect syntax near
'1'" error message from below fill line,

objDataAdapter.Fill(objDataSet, "mindata")
any help is greatly appriciated.

Jun 22 '06 #4
There is nothing obvious that could possibly cause that error message
using that query.

Is there something less obvious going on? Is mindata a view? Do you have
any triggers in the database?

martin1 wrote:
the whole program is :

Imports System.Data
Imports System.Data.SqlClient
Public Class GreeneCTControlRoom
Dim objConnection As New SqlConnection _
("Server=server1; database=db1;user id=sa;password=whatever")
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As New DataSet()
Private Sub GreeneCTControlRoom_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = _
"Select Parameter, Average, Units from mindata"
objDataAdapter.SelectCommand.CommandText = CommandType.Text

objConnection.Open()
objDataAdapter.Fill(objDataSet, "mindata")
objConnection.Close()

grdControlRoom.AutoGenerateColumns = True
grdControlRoom.DataSource = objDataSet
grdControlRoom.DataMember = "mindata"

objDataAdapter = Nothing
objConnection = Nothing

End Sub
End Class
"Göran Andersson" wrote:
The error refers to a syntax error in the SQL query you are using to get
the data. What does the SQL query look like?

martin1 wrote:
I just use DataSet to bind DataSetGrid and display from SQL DB.
when starting run in Visual Studio 2005, get "Line 1: Incorrect syntax near
'1'" error message from below fill line,

objDataAdapter.Fill(objDataSet, "mindata")
any help is greatly appriciated.

Jun 23 '06 #5
I figure out, I type something wrong, it should be

objDataAdapter.SelectCommand.CommandType = CommandType.Text

then work

Thanks
"Göran Andersson" wrote:
There is nothing obvious that could possibly cause that error message
using that query.

Is there something less obvious going on? Is mindata a view? Do you have
any triggers in the database?

martin1 wrote:
the whole program is :

Imports System.Data
Imports System.Data.SqlClient
Public Class GreeneCTControlRoom
Dim objConnection As New SqlConnection _
("Server=server1; database=db1;user id=sa;password=whatever")
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As New DataSet()
Private Sub GreeneCTControlRoom_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = _
"Select Parameter, Average, Units from mindata"
objDataAdapter.SelectCommand.CommandText = CommandType.Text

objConnection.Open()
objDataAdapter.Fill(objDataSet, "mindata")
objConnection.Close()

grdControlRoom.AutoGenerateColumns = True
grdControlRoom.DataSource = objDataSet
grdControlRoom.DataMember = "mindata"

objDataAdapter = Nothing
objConnection = Nothing

End Sub
End Class
"Göran Andersson" wrote:
The error refers to a syntax error in the SQL query you are using to get
the data. What does the SQL query look like?

martin1 wrote:
I just use DataSet to bind DataSetGrid and display from SQL DB.
when starting run in Visual Studio 2005, get "Line 1: Incorrect syntax near
'1'" error message from below fill line,

objDataAdapter.Fill(objDataSet, "mindata")
any help is greatly appriciated.

Jun 23 '06 #6
Yes, now I see it. The CommandType.Text value is automatically converted
to the number 1, and then automatically converted to the string "1".

You should use Option Strict On to avoid these unintentional conversions.

martin1 wrote:
I figure out, I type something wrong, it should be

objDataAdapter.SelectCommand.CommandType = CommandType.Text

then work

Thanks
"Göran Andersson" wrote:
There is nothing obvious that could possibly cause that error message
using that query.

Is there something less obvious going on? Is mindata a view? Do you have
any triggers in the database?

martin1 wrote:
the whole program is :

Imports System.Data
Imports System.Data.SqlClient
Public Class GreeneCTControlRoom
Dim objConnection As New SqlConnection _
("Server=server1; database=db1;user id=sa;password=whatever")
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As New DataSet()
Private Sub GreeneCTControlRoom_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = _
"Select Parameter, Average, Units from mindata"
objDataAdapter.SelectCommand.CommandText = CommandType.Text

objConnection.Open()
objDataAdapter.Fill(objDataSet, "mindata")
objConnection.Close()

grdControlRoom.AutoGenerateColumns = True
grdControlRoom.DataSource = objDataSet
grdControlRoom.DataMember = "mindata"

objDataAdapter = Nothing
objConnection = Nothing

End Sub
End Class
"Göran Andersson" wrote:

The error refers to a syntax error in the SQL query you are using to get
the data. What does the SQL query look like?

martin1 wrote:
> I just use DataSet to bind DataSetGrid and display from SQL DB.
> when starting run in Visual Studio 2005, get "Line 1: Incorrect syntax near
> '1'" error message from below fill line,
>
> objDataAdapter.Fill(objDataSet, "mindata")
>
>
> any help is greatly appriciated.

Jun 23 '06 #7

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

Similar topics

0
by: samuel | last post by:
Hi I wrote a macro in MS Access 2000. This is a .adp link on SQL server tables. I have 2 forms: script_selection & Form3 Form3 include 2 important fields: CD & line I want to write a...
2
by: Roger R. Smith | last post by:
I see this error in my ASP .NET code: I am trying to execute the following: private const string SQL_SELECT_USER = "SELECT User.Email, User.FirstName, User.LastName, User.Status, User.Phone,...
1
by: bdastani | last post by:
I am trying to initialize a dataReader in C#, but I keep on gettin an exception error stating the following: System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior,...
3
by: Patrick.O.Ige | last post by:
Hi guys, I'm getting error:- System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '='. What could cause this ERRORR My code below:- Dim connString As String =...
1
by: Sandesh | last post by:
Hello All, Me saying " has any body come across such error would be underestimating". Well I am getting a very peculiar and unique error "Line 1: Incorrect syntax near 'Actions'." ...
1
by: iporter | last post by:
In the following code, the two Response.Write statements output exactly the same - I can copy and paste both into Query Analyzer, and run them fine. However, if I comment out line 3, the...
1
by: Ruth413 | last post by:
Hello - I am getting the these errors in my sql 2005 generated script. I am stuck with first error. Please help.... Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '('. Msg 319,...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
5
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Hi, What is wrong with this code ? I got this error: " Line 1: Incorrect syntax near 'sp_Collect'. " which appears at the last line when | call the cm.ExecuteScalar . The sp takes an int ID...
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: 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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.