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!

SQL query, how ? 1

Status
Not open for further replies.

HadiRezaee

Technical User
Mar 9, 2001
165
0
0
IR
Hi,
I'm using Crystal Report 8.0 ...
I need to find a record its Code field is 120 ...
So, first i made the new report with Standard expert ...
Then i choosed all fields that i need ...
But i don't know where i can write SQL !!!
So, please tell me how can i write SQL in my report ...

Thanks,
Hadi Rezaie
 
Hadi,

Go to REPORT, SELECT EXPERT. Click on NEW. Select "CODE FIELD" With the drop down box, Select "equal to", then type "120" Click OK and there ya go!

hth,
Smitty
 
Hadi,

Smitty's solution will correctly select the record you want. If you really need to work in SQL though, go to the Database menu and choose "Show SQL Query" to see and edit it. It will take into account the record selection formula as a Where clause.

Scott
 
Hi Smitty020 and thanks for your reply ...
Now, i want to know how can i use dynamic query ...
I mean using of this query in run-time in my program ...
I used SetSQLQuery() function:
m_Crystal.SetSQLQuery("SELECT * FROM PERSON WHERE
Code:
 = 1");
But this code won't work !!!
How can use dynamic query ?
 
Hadi,

First let Crystal create it by setting a record selection formula as Smitty described. Then look at the SQL using the method I listed. Then use that as a template to set the SQL string from VB.

An alternative to setting the SQL string is to set the record selection formula from VB. If you need the syntax, create one with the wizard, then edit it to see how Crystal sets it up. Both have the same outcome, and I think execute with the same speed as Crystal creates the SQL expression from the record selection formula and passes that to the data source.

What is the problem you are having? Are you getting an error; Is it not returning the correct records? One reason to see how Crystal sets up the string is to see exactly how it refers to your data table. Just refering to "PERSON" may not be sufficient for Crystal to find the table.

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top