arulkumarske
asked on
There was an error Parsing the Query. [Token Line number = 1, Token Line offset =1, Token in error = 1 ].
I am Using SqlcedataReader in Sql server Compact Edition 3.5, but when the application runs the Execute reader Method. It is throwing the error message as There was an error Parsing the Query. [Token Line number = 1, Token Line offset =1, Token in error = 1 ]. If i execute the query in Management Studio it is working. If any body knows the answer request to help me in this regards,
Regards,
Arul Kumar
Regards,
Arul Kumar
sSql = "SELECT * From TMOBIHUBCE;"
cmdSKU = New SqlCeCommand(sSql, oNewConnection)
cmdSKU.CommandText = CommandType.Text
rdrReadSKU = cmdSKU.ExecuteReader(CommandBehavior.Default)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this error is popular error and used to come when you have something wrong in SQL Syntax but in your case I can't find any wrong syntax, are you using the same code? or it is a part of bigger query?
ASKER
Hi Ritesh,
1. This is the Query i am using. There will be always only record only.
Request to help me in this regards.
Thanks in Advance.
Regards,
Arul Kumar.
1. This is the Query i am using. There will be always only record only.
Request to help me in this regards.
Thanks in Advance.
Regards,
Arul Kumar.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can you please post your full code? I just wanted to sure whether you are missing something. moreover, can you try by using field name instead of "*" in query? I know this is not a solution but just give it a try.
ASKER
Hi ritesh,
1. Attached the Code Snippet, request to help me in this regards,
Arul Kumar
1. Attached the Code Snippet, request to help me in this regards,
Arul Kumar
Private Sub BCRReceive_BarcodeRead(ByVal sender As System.Object, ByVal bre As Intermec.DataCollection.BarcodeReadEventArgs) Handles BCRReceive.BarcodeRead
Dim rdrReadSKU As SqlCeDataReader = Nothing
Dim sDeviceName As String = System.Net.Dns.GetHostName()
Dim oNewConnection As SqlCeConnection = Nothing
Dim ceEng As SqlCeEngine = Nothing
Dim iQty As Integer = 0
Dim sBatchCode As String = String.Empty
'Code For Reading Barcode and Fetch the SKU Details
Dim sConnectionString As String = "Data Source= " + GetAppPath() + "\MOBIHUB.sdf;"
Try
txtSKU.Text = bre.strDataBuffer.ToString
Dim sSql As String = String.Empty
Dim sActCode As String = String.Empty
Dim cmdSKU As SqlCeCommand
sConnectionString = "Data Source= " + GetAppPath() + "\MOBIHUB.sdf;"
oNewConnection = New SqlCeConnection(sConnectionString)
oNewConnection.Open()
sSql = "SELECT * From TMOBIHUBCE"
cmdSKU = New SqlCeCommand(sSql, oNewConnection)
cmdSKU.CommandText = CommandType.Text
rdrReadSKU = cmdSKU.ExecuteReader()
While rdrReadSKU.Read
rdrReadSKU.Read()
sBatchCode = rdrReadSKU.GetValue(2)
iQty = rdrReadSKU.GetValue(3)
txtBatchCode.Text = sBatchCode
txtPUOMQty.Text = iQty
End While
If rdrReadSKU.IsClosed = False Then
rdrReadSKU.Close()
rdrReadSKU.Dispose()
End If
Catch ex As Exception
MsgBox(ex.ToString)
' ManageMobileHub.cManageLogs.ManageLogs(System.Guid.NewGuid.ToString, ex.ToString)
Finally
oNewConnection.Close()
End Try
End Sub
Public Shared Function GetAppPath() As String
Dim fullPath As String = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)
GetAppPath = fullPath
End Function
ASKER
hI aneeshattingal
I have tried set nocount on: it is throwing the same error. I am using Sqlce 3.5, .NET Compact Framework 2.0 SP2 and VS 2005. Request ot help me in this regards, Attached Code Reference
Regards,
Arul Kumar.
I have tried set nocount on: it is throwing the same error. I am using Sqlce 3.5, .NET Compact Framework 2.0 SP2 and VS 2005. Request ot help me in this regards, Attached Code Reference
Regards,
Arul Kumar.
Private Sub BCRReceive_BarcodeRead(ByVal sender As System.Object, ByVal bre As Intermec.DataCollection.BarcodeReadEventArgs) Handles BCRReceive.BarcodeRead
Dim rdrReadSKU As SqlCeDataReader = Nothing
Dim sDeviceName As String = System.Net.Dns.GetHostName()
Dim oNewConnection As SqlCeConnection = Nothing
Dim ceEng As SqlCeEngine = Nothing
Dim iQty As Integer = 0
Dim sBatchCode As String = String.Empty
'Code For Reading Barcode and Fetch the SKU Details
Dim sConnectionString As String = "Data Source= " + GetAppPath() + "\MOBIHUB.sdf;"
Try
txtSKU.Text = bre.strDataBuffer.ToString
Dim sSql As String = String.Empty
Dim sActCode As String = String.Empty
Dim cmdSKU As SqlCeCommand
sConnectionString = "Data Source= " + GetAppPath() + "\MOBIHUB.sdf;"
oNewConnection = New SqlCeConnection(sConnectionString)
oNewConnection.Open()
sSql = "SELECT * From TMOBIHUBCE"
cmdSKU = New SqlCeCommand(sSql, oNewConnection)
cmdSKU.CommandText = CommandType.Text
rdrReadSKU = cmdSKU.ExecuteReader()
While rdrReadSKU.Read
rdrReadSKU.Read()
sBatchCode = rdrReadSKU.GetValue(2)
iQty = rdrReadSKU.GetValue(3)
txtBatchCode.Text = sBatchCode
txtPUOMQty.Text = iQty
End While
If rdrReadSKU.IsClosed = False Then
rdrReadSKU.Close()
rdrReadSKU.Dispose()
End If
Catch ex As Exception
MsgBox(ex.ToString)
' ManageMobileHub.cManageLogs.ManageLogs(System.Guid.NewGuid.ToString, ex.ToString)
Finally
oNewConnection.Close()
End Try
End Sub
Public Shared Function GetAppPath() As String
Dim fullPath As String = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)
GetAppPath = fullPath
End Function
ASKER
at last i have found the Solution for it. The Solution is That the Change the Declarations to the top of the Function and Put te ssql above the connection Initialization. Then it works. I don't know it is the reason. but any how it works. Thank you very much for all who posted the comments and give me the suggestions.
Thanks & regards,
Arul Kumar
Thanks & regards,
Arul Kumar
ASKER
Still Same Error Persists, Attached the Changed Code for reference. Request to help me in this regards.
Regards,
Arul Kumar
Open in new window