473,407 Members | 2,546 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,407 software developers and data experts.

Sorting Datagrid problem

Pat
I'm trying to do a sorting in a Datagrid below but i'm getting
ERRROR:- "Line 1: Incorrect syntax near 'CompanyID'."
strQuery = "Select InvoiceDate,OrderDate From CMRC_Orders ORDER BY " & _
viewstate("sortField").ToString & "" & _
viewstate("sortdirection") & "" & _
"where CompanyID = " & myDropDownList.SelectedItem.Value

Any ideas 'm passing the DropDwon Selected value because thats what i use to
populate the Datagrid
Nov 19 '05 #1
4 1128
Um..it is hard to tell because of the formatting of the post..

Here goes..

1) When using dynamic Sql ..it is a good thing to Response.Write the Query
to make sure it is getting all the values required to run successfully..

2) It also gives an indication of any formatting errors in the query ie:
missing commas, spaces ect.

It could be the formating in the post but you could be missing some
spaces...
A "" may not provide the space provided by " ".

Failing that check your value parameters.

Also you haven't specified a rdbms which is usually helpful when dealing
with sql problems.
I am assuming SQL Server..

Cheers,
Adam
Ps: So where are you from?

"Pat" <na********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
I'm trying to do a sorting in a Datagrid below but i'm getting
ERRROR:- "Line 1: Incorrect syntax near 'CompanyID'."
strQuery = "Select InvoiceDate,OrderDate From CMRC_Orders ORDER BY " & _
viewstate("sortField").ToString & "" & _
viewstate("sortdirection") & "" & _
"where CompanyID = " & myDropDownList.SelectedItem.Value

Any ideas 'm passing the DropDwon Selected value because thats what i use
to
populate the Datagrid

Nov 19 '05 #2
Hi Pat,

Are you missing the quote for the CompanyID value?

Regards,
Jack Li
MVP (ASP.NET)

"Pat" <na********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
I'm trying to do a sorting in a Datagrid below but i'm getting
ERRROR:- "Line 1: Incorrect syntax near 'CompanyID'."
strQuery = "Select InvoiceDate,OrderDate From CMRC_Orders ORDER BY " & _
viewstate("sortField").ToString & "" & _
viewstate("sortdirection") & "" & _
"where CompanyID = " & myDropDownList.SelectedItem.Value

Any ideas 'm passing the DropDwon Selected value because thats what i use
to
populate the Datagrid

Nov 19 '05 #3
"Pat" <na********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
I'm trying to do a sorting in a Datagrid below but i'm getting
ERRROR:- "Line 1: Incorrect syntax near 'CompanyID'."
strQuery = "Select InvoiceDate,OrderDate From CMRC_Orders ORDER BY " & _
viewstate("sortField").ToString & "" & _
viewstate("sortdirection") & "" & _
"where CompanyID = " & myDropDownList.SelectedItem.Value

Any ideas 'm passing the DropDwon Selected value because thats what i use
to
populate the Datagrid


Er, unless I'm missing something blindingly obvious...

1) you don't have spaces in your SQL - change "" to " "
2) you've got your ORDER BY clause before your WHERE clause...
Nov 19 '05 #4
Pat
Thx guys
My ORDER BY clause was before WHERE
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:us**************@TK2MSFTNGP15.phx.gbl...
"Pat" <na********@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
I'm trying to do a sorting in a Datagrid below but i'm getting
ERRROR:- "Line 1: Incorrect syntax near 'CompanyID'."
strQuery = "Select InvoiceDate,OrderDate From CMRC_Orders ORDER BY " & _
viewstate("sortField").ToString & "" & _
viewstate("sortdirection") & "" & _
"where CompanyID = " & myDropDownList.SelectedItem.Value

Any ideas 'm passing the DropDwon Selected value because thats what i use to
populate the Datagrid


Er, unless I'm missing something blindingly obvious...

1) you don't have spaces in your SQL - change "" to " "
2) you've got your ORDER BY clause before your WHERE clause...

Nov 19 '05 #5

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

Similar topics

0
by: Chris Mayers | last post by:
I have a Windows Forms DataGrid that has a DataView as a datasource. My problem is that I want the datagrid to exhibit some special sorting properties when the header rows are clicked on. From...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: Gary | last post by:
Hi, We are facing a typical problem with sorting a datagrid in Windows application ( c# ) The scenario We have a datagrid which is binded to a dataview which conatins two columns say Name...
1
by: Sargas Atum | last post by:
Hi all, 1. I have a problem with cell selection in a table in a DataGrid. I dont want that anybody writes in the cells. That was not a problem I changed them to "read only", but if I am going...
1
by: bredal Jensen | last post by:
Hello, I'am experiencing that Asp.net can not handle sorting of datagrid when the number of items exceed a few thousands. Is anyone aware of this problem? The sorting works fine when the number...
2
by: saleek | last post by:
Hi, I am trying to figure out why my datagrid has stopped firing the page and sort commands. Scenario: I originally had template columns in my datagrid and had set up custom bi-directional...
8
by: simchajoy2000 | last post by:
I thought the only thing I had to do to disable column sorting in VB.NET was to set datagrid.AllowSorting = False. Unfortunately this has never worked for me. I discovered another set of code...
4
by: Ambica Jain | last post by:
Hi, I want custom sorting on some of the columns in the datagrid. And i am able to do the same by overriding MouseDown event. However, i need to rebind my datatable to reflect the changes in...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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...
0
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...

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.