CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Incorrect syntax near the keyword 'ORDER'.

Print topic Send  topic

Author Message
Oscar
Posted: 10/30/2006, 1:54 AM

Hi

I have a problem. I work with Codecharge v3.0 building an ASP website with
SQL Server

I have a grid that show me a query that it execute with or without
parameters. When I acces to this ASP page for the first time, i dont send
any parameter, so i create a custon code in BEFORE SELECT event then has
this structure

SELECT obra_c, obras.id AS obras_id, destacado, obra_p, obra_i, lugar, ano
FROM obras

If i execute this query, page show me results

But i need to see this results order by one field, so i modify this query
like this

SELECT obra_c, obras.id AS obras_id, destacado, obra_p, obra_i, lugar, ano
FROM obras order by destacado desc

if i load this page, it gives me this error

Form: Grid obras
Error: Incorrect syntax near the keyword 'ORDER'. (Microsoft OLE DB Provider
for SQL Server)


I tried to execute this query in the control panel of SQL Server and also en
TOAD SQL SERVER, and this execute correctly.

Grid ("obras") is declared as :
siguiente forma

DataSourceType: SQL
DataSource= SELECT distinct obras.id AS obras_id, destacado, obra_c, obra_p,
obra_i, lugar, ano
FROM obras LEFT JOIN ((obras_materiales LEFT JOIN cat_familia ON
obras_materiales.familia = cat_familia.id) LEFT JOIN cat_gama ON
obras_materiales.gama = cat_gama.id) ON
obras.id = obras_materiales.obra
WHERE obras.tipo like '%{tipoobra}%'
AND cat_gama.uids LIKE '%{uid}%'
AND cat_gama.id={gama}
AND cat_familia.uids LIKE '%{uid}%'
ORDER BY obra_c


custom code is in event BeforeSelect and it is declares as:

dim sq
sq="SELECT obra_c, obras.id AS obras_id, destacado, obra_p, obra_i, lugar,
ano FROM obras order by destacado desc"
obras.DataSource.SQL = sq

Can anybody help me?

Thanks

mrachow


Posts: 509
Posted: 10/30/2006, 4:22 AM

Having not dived very deep into your stuff but it's possible that your sql gets extended by a second order by clause created by studio.

You can use the grids datasouce query without having the parameter values already. Studio will always remove empty parameters from the query.
_________________
Best regards,
Michael
View profile  Send private message
Oper


Posts: 1195
Posted: 10/31/2006, 5:55 AM

when you get burned in some SQL grid/report/etc

Do this on the event before execute SQL
  
response.write formname.DataSource.SQL  
response.write "<br>------------<br>"  
response.write formname.DataSource.SQL.where  
response.end                  <---------------------- This may be no netcesry (depend on your logic)  

_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
Oper


Posts: 1195
Posted: 10/31/2006, 6:04 AM

when you get burned in some SQL grid/report/etc

Do this on the event before execute SQL
  
response.write formname.DataSource.SQL  
response.write "<br>------------<br>"  
response.write formname.DataSource.where  
response.end                  <---------------------- This may be no netcesry (depend on your logic)  

Fixed Here
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.