|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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. 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: Show quoteHide quote > 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. it is
objDataAdapter.SelectCommand.CommandText = _ "Select Parameter, Average, Units from mindata" Thanks Show quoteHide quote "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. > 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 Show quoteHide quote "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. > 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: Show quoteHide quote > 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. I figure out, I type something wrong, it should be
objDataAdapter.SelectCommand.CommandType = CommandType.Text then work Thanks Show quoteHide quote "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. > 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: Show quoteHide quote > 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.
Unicode API
How to assign a state to checkbox in Visual Basic.net ? putting a line on my form simple graphics question Programatically create a Stored Procedure Paramters passing and RunWorkerCompleted event Accessing Login info Reference to a control, by its name in a String Executing a stored procedure that uses linked server from vb.NET Visual Studio 2005 Pro |
|||||||||||||||||||||||