Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the SQL statement in Crystal Reports 1

Status
Not open for further replies.

CH

Programmer
Oct 15, 1999
6
0
0
US
I am new to Crystal Reports and having a hard time. I am using Crystal Reports with a Sybase database and a VB application where the user can query on 20 different fields. I build the sql statement in VB as the user builds his/her criteria. The SELECT section selects the same fields for every query but the WHERE section changes depending on the users criteria. How do I get Crystal Reports to read the new sql statement?<br>
<br>
example #1 select name, citizenship from tvisitors where name like &quot;%sam%&quot;<br>
example #2 select name, citizenship from tvisitors v, tfacilities f where v.citizenship = &quot;US&quot; and f.age &gt; 20 and <br>
f.type = &quot;Government&quot; and f.visitorid = v.visitorid;
 
The following is from <br>
<A HREF=" TARGET="_new"> <br>
and I think addresses your problem:<br>
<br>
Synopsis<br>
Pass a multiple line Sql Query using the SQLQUERY property so that the whole statement is on seperated lines.<br>
<br>
Solution<br>
For example the SQL query:<br>
sql_str = &quot;SELECT Orders.`Order ID`, Orders.`Customer`, Orders.`Date`, Orders.`Order Amount` FROM `Orders` Orders WHERE (((Orders.`Order Date`) = #01/27/96#))&quot;<br>
<br>
must be concatenated as:<br>
<br>
sql_str = &quot;SELECT&quot; _<br>
+&quot;Orders.`Order ID`, Orders.`Customer`, Orders.`Date`, Orders.`Order Amount`&quot; _<br>
+ &quot;FROM &quot; _<br>
+ &quot; `Orders` Orders&quot; _<br>
+ &quot; WHERE &quot; _<br>
+ &quot; (((Orders.`Order Date`) = #01/27/96#))&quot;<br>
& sign can be used instead of the + sign.<br>
<p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Thank you for your response. I just wanted to make an addition for anyone who might have the same problem. When sending the sql statement using the SQLQUERY the ORDER BY clause was still giving me problems. It turns out that the ORDER BY clause requires a carriage return and linefeed to preceed the ORDER BY.<br>
<br>
<br>
sql_str =
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top