473,789 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2987
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.C ommandText = _
"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.Sql Client
Public Class GreeneCTControl Room
Dim objConnection As New SqlConnection _
("Server=server 1; database=db1;us er id=sa;password= whatever")
Dim objDataAdapter As New SqlDataAdapter( )
Dim objDataSet As New DataSet()
Private Sub GreeneCTControl Room_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
objDataAdapter. SelectCommand = New SqlCommand()
objDataAdapter. SelectCommand.C onnection = objConnection
objDataAdapter. SelectCommand.C ommandText = _
"Select Parameter, Average, Units from mindata"
objDataAdapter. SelectCommand.C ommandText = CommandType.Tex t

objConnection.O pen()
objDataAdapter. Fill(objDataSet , "mindata")
objConnection.C lose()

grdControlRoom. AutoGenerateCol umns = 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.Sql Client
Public Class GreeneCTControl Room
Dim objConnection As New SqlConnection _
("Server=server 1; database=db1;us er id=sa;password= whatever")
Dim objDataAdapter As New SqlDataAdapter( )
Dim objDataSet As New DataSet()
Private Sub GreeneCTControl Room_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
objDataAdapter. SelectCommand = New SqlCommand()
objDataAdapter. SelectCommand.C onnection = objConnection
objDataAdapter. SelectCommand.C ommandText = _
"Select Parameter, Average, Units from mindata"
objDataAdapter. SelectCommand.C ommandText = CommandType.Tex t

objConnection.O pen()
objDataAdapter. Fill(objDataSet , "mindata")
objConnection.C lose()

grdControlRoom. AutoGenerateCol umns = 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.C ommandType = CommandType.Tex t

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.Sql Client
Public Class GreeneCTControl Room
Dim objConnection As New SqlConnection _
("Server=server 1; database=db1;us er id=sa;password= whatever")
Dim objDataAdapter As New SqlDataAdapter( )
Dim objDataSet As New DataSet()
Private Sub GreeneCTControl Room_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
objDataAdapter. SelectCommand = New SqlCommand()
objDataAdapter. SelectCommand.C onnection = objConnection
objDataAdapter. SelectCommand.C ommandText = _
"Select Parameter, Average, Units from mindata"
objDataAdapter. SelectCommand.C ommandText = CommandType.Tex t

objConnection.O pen()
objDataAdapter. Fill(objDataSet , "mindata")
objConnection.C lose()

grdControlRoom. AutoGenerateCol umns = 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.Tex t 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.C ommandType = CommandType.Tex t

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.Sql Client
Public Class GreeneCTControl Room
Dim objConnection As New SqlConnection _
("Server=server 1; database=db1;us er id=sa;password= whatever")
Dim objDataAdapter As New SqlDataAdapter( )
Dim objDataSet As New DataSet()
Private Sub GreeneCTControl Room_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
objDataAdapter. SelectCommand = New SqlCommand()
objDataAdapter. SelectCommand.C onnection = objConnection
objDataAdapter. SelectCommand.C ommandText = _
"Select Parameter, Average, Units from mindata"
objDataAdapter. SelectCommand.C ommandText = CommandType.Tex t

objConnection.O pen()
objDataAdapter. Fill(objDataSet , "mindata")
objConnection.C lose()

grdControlRoom. AutoGenerateCol umns = 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
1621
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 macro who will be run when I click on a field (line) in
2
4368
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, User.Privs FROM User INNER JOIN Login ON User.UserId = Login.UserId WHERE Login.UserId = @UserId AND Login.Password = @Password";
1
3426
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, RunBehavior runBehavior, Boolean returnStream) System.Data.SqlClient.SqlCommand.ExecuteReader() Labor.Labor.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\labor\labor.aspx.cs:72 System.Web.UI.Control.OnLoad(EventArgs e)
3
6057
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 = "server=(local);database=Northwind;integrated security=true;" Dim objConnection As SqlConnection objConnection = New SqlConnection(connString) objConnection.Open()
1
11255
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'." Explaining you the scene is the following Stored Proc.
1
2356
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 assignment of "SELECT T..." to the variable query, the last line produces the error: Line 1: Incorrect syntax near '<'. Many thanks in advance for any explanation - the problem is tearing my hair out!! Iain
1
31207
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, Level 15, State 1, Line 11 Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
0
8331
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 records there is an error "Incorrect syntax near '-'. Must declare the scalar variable "@UserName". I worked out in design view,code is automatically generated.Iam not able fix the error. Iam working with Visual Web Developer-2005 Express Edition
5
4497
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 and returns a string Data. Using the debugger, I see that the value of ID is correct. Is this a C# problem, or SQL Server 7 problem ?
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
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 we have to send another system
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.