Hi! I&#039ve recently read an article(with example) on DataShaping(hierarchical recordsets) and tried to implement it in my ASP page with my database.The idea is to generate a report of orders grouped by orderid(each in a separate table).This has two recordsets:one containing the orderid and the other containing the details.<BR>But I&#039m getting a syntax error at the SQL statement.<BR><BR>Microsoft OLE DB Provider for SQL Server error &#039 80040e14&#039 <BR>Syntax error or access violation <BR>/kams/sample_v3.asp, line 24 <BR><BR>Can anybody tell me where I&#039m going wrong?<BR>Thanks<BR>The code is:<BR><BR>&#060;%dim conn%&#062;<BR>&#060;%dim rs1%&#062;<BR>&#060;%dim rs2%&#062;<BR>&#060;%set conn = server.CreateObject("adodb.connection")%&#062;<BR> &#060;%set rs1 = server.CreateObject("adodb.recordset")%&#062;<BR>& #060;%conn.Open connectionstring%&#062;<BR>&#060;%strShape = "shape { select orderid from orderheader where orderstatus=1 }" & _%&#062;<BR>&#060;%"as header append ({ select d.orderid,d.lineitemnumber,p.productname from orderdetail d,products p " & _%&#062;<BR>&#060;%" where d.productid = p.productid } as details " & _%&#062;<BR>&#060;%"relate orderid to orderid) as orders"%&#062;<BR>&#060;%rs1.Open strShape,conn%&#062; -----&#062;syntax error occuring here<BR>&#060;%if not rs1.BOF then%&#062;<BR> &#060;%do while not rs1.EOF%&#062;<BR> &#060;table width=100% border=0 align=center&#062;<BR> &#060;tr&#062;<BR> &#060;th align="left"&#062;&#060;font face="arial" size=2&#062;OrderID: &#060;%=rs1("orderid")%&#062;&#060;/font&#062;&#060;/th&#062;<BR> &#060;/tr&#062;<BR> &#060;tr&#062;<BR> &#060;th width=20% align=center&#062;&#060;font face="arial" size=2&#062;LineItem#&#060;/font&#062;&#060;/th&#062;<BR> &#060;th width=80% align=center&#062;&#060;font face="arial" size=2&#062;Product&#060;/font&#062;&#060;/th&#062;<BR> &#060;/tr&#062;<BR> &#060;%set rs2 = rs1("orders").value%&#062;<BR> &#060;%do while not rs2.eof%&#062;<BR> &#060;tr&#062;<BR> &#060;td align="left"&#062;&#060;font face="arial" size=2&#062;&#060;%=rs2("lineitemnumber")%&#062;&# 060;/font&#062;&#060;/td&#062;<BR> &#060;td align="left"&#062;&#060;font face="arial" size=2&#062;&#060;%=rs2("productname")%&#062;&#060 ;/font&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;%rs2.movenext%&#062;<BR> &#060;%loop%&#062;<BR> &#060;%rs1.MoveNext%&#062;<BR> &#060;%loop%&#062;<BR> &#060;/table&#062;<BR>&#060;%else%&#062;<BR> &#060;center&#062;&#060;font face="arial" size=2&#062;&#060;b&#062;No records&#060;/b&#062;&#060;/font&#062;&#060;/center&#062;<BR>&#060;%end if%&#062;<BR>&#060;%rs1.close%&#062;<BR>&#060;%set rs1 = nothing%&#062;<BR>&#060;%set rs2 = nothing%&#062;<BR>&#060;%conn.close%&#062;<BR>&#06 0;%set conn = nothing%&#062;<BR>