If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > CROSS tab query using asp and sql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-07, 17:09
cherubiclad cherubiclad is offline
Registered User
 
Join Date: Apr 2007
Posts: 3
Talking CROSS tab query using asp and sql

I have created crosstab query in access and pasted the same code into asp.The code is working fine when i use access but does not work when i use SQL.Following is the code

<%@ LANGUAGE="VBSCRIPT" %>
<%
Dim objConn
Dim objRS
Dim strSQL
Dim strConnection
Dim i


Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")


const c_databaseType = "SQL"
const c_odbcBridge = "E2E"
const c_dbUID = "amse2e"
const c_dbPwd = "amse2e"

objConn.Open "DSN=" & c_odbcBridge, c_dbUID, c_dbPwd


strSQL ="TRANSFORM Count(order_no) AS 'CountOforder_no' SELECT Orders.duedate, status, Count (order_no) AS 'Total Of order_no'FROM dbo_Orders WHERE (((status)='I'))GROUP BY duedate, status PIVOT country"
set objRS = objConn.Execute (strSQL)


if (objRS.BOF and objRS.EOF) then
response.write "No records found"
response.end
End if

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>

<BODY>
<TABLE BORDER="1" CELLPADDING="2" CELLSPACING="1" WIDTH="100%">
<%

Response.Write "<TR BGCOLOR=""#CCCCCC"">"
For i = 0 to objRS.Fields.Count - 1
Response.Write "<TH><FONT FACE=""ARIAL"" SIZE=""2"">" & objRS.Fields(i).Name & "</FONT></TH>"
Next
Response.write "</TR>"
' -- Now output the contents of the Recordset
objRS.MoveFirst
Do While Not objRS.EOF
' -- output the contents
Response.Write "<TR>"
For i = 0 to objRS.Fields.Count - 1
Response.Write "<TD><FONT FACE=""ARIAL"" SIZE=""1"">" & objRS.Fields(i) & "</FONT></TD>"
Next
Response.write "</TR>"
' -- move to the next record
objRS.MoveNext
Loop

objRS.Close
set objRS = Nothing
objConn.Close
set objConn = Nothing




%>
</TABLE>


</BODY>
</HTML>

I get the following error

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'order_no'.

please help me
plz
Reply With Quote
  #2 (permalink)  
Old 04-13-07, 19:58
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Code:
strSQL ="TRANSFORM Count(order_no) AS 'CountOforder_no' SELECT Orders.duedate, status, Count (order_no) AS 'Total Of order_no'FROM
Is it perhaps the space in Count (order_no) ?
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 04-16-07, 16:00
cherubiclad cherubiclad is offline
Registered User
 
Join Date: Apr 2007
Posts: 3
I get same error

i cud not solve it plz help me
Reply With Quote
  #4 (permalink)  
Old 04-16-07, 17:50
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
How about changing Count(Order_No) to Count(*) ?
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 04-17-07, 11:14
cherubiclad cherubiclad is offline
Registered User
 
Join Date: Apr 2007
Posts: 3
I have used Count(*)


Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '*'.

this is the error i get
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On