p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Crystal Reports for VS.NET (http://p2p.wrox.com/forumdisplay.php?f=45)
-   -   Dynamically Changing SQL Commands? (http://p2p.wrox.com/showthread.php?t=13131)

avantjer May 18th, 2004 03:27 PM

Dynamically Changing SQL Commands?
I have developed an ASP.NET application that uses an “SQL Command” as described in the section “Working with SQL Commands" on page 181. I need to be able to change that command programmatically at runtime but I can’t find a way to do it. The change I would make would be to the WHERE clause, and the resulting table would have the same format as that specified in the report designer. Is there a way to alter the SQL Command programmatically, on the fly, at runtime?

Thank you…


bmains May 18th, 2004 03:55 PM


Sure you can dynamically build a command. It sounds like you're creating dynamic SQL though; so none of the SQL queries can be predefined in advanced? If not, you can use string manipulation or regular expressions to parse apart the SQL string.

strSQL = strSQL.Substring(0, strSQL.indexOf(" WHERE "))


' \. means any characters, and the + means one or more
strSQL = Regex.Replace(strSQL, " WHERE \.+", "")

Something like that,


melvik May 18th, 2004 11:29 PM

u just make a string as a command & run set to a command Obj, this will be ur dynamic Command! So simple.

Hovik Melkomian.

All times are GMT -4. The time now is 09:29 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.