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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic SQL

Status
Not open for further replies.

xenomage

Programmer
Jun 27, 2001
98
SG
Hi,

i need to build a dynamic SQL statement for use with crystal report.

However, the SQL editor does not allow me to use user input as part of the SQL string.

There must be a way to do it. Please help. Many Thanks.

xeno.
 
If you are using CR9 or later then you can use Parameters for user input.

 
Thanks for the information.

But that's what i'm trying to do. i not sure how to use the user-input and place it in the SQL statement.

Please help. Many Thanks.
 
It depends on how dynamic you're trying to be. The columns returned will probably need to always be the same data type, or you'll get unexpected errors. Here's a simple example:

I've got 3 string parameters defined:
1) {?a_Select},
2) {?b_From}, and
3) {?c_Where}

Here is the text of my SQL Command:
[tt]
{?a_Select}
{?b_From}
{?c_Where}
[/tt]
And this is what I enter for each prompt:
1) SELECT CollegeID, Name
2) FROM College
3) WHERE CollegeID > 5

Hope that helps you get started. Stating your intent will assist someone here in helping you more specifically.

-dave
 
Please post technical information:

Crystal version
Database/connectivity used
Example data
Expected output

Dynamic SQL can be as simple as adjusting a where clause, or you may need a completely different SQL statement, but you're the only one who knows the requirement, and you're not sharing ;)

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top