CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> .NET

 How to get where clause of a grid?

Print topic Send  topic

Author Message
worldofabhilash

Posts: 3
Posted: 07/13/2007, 3:15 PM

Hi,

I need to pass the where clause of the the grid to another form. I have used the following code to store the value of the where clause to a session variable:

The code is written in the Before execute select event :

if HttpContext.Current.Session("sqlWhere") = nothing then
HttpContext.Current.Session.Add("sqlWhere","")
end if
if DirectCast(Select_,TableCommand).Where.ToString() <> "" then
HttpContext.Current.Session("sqlWhere") = CType(Select_ ,TableCommand).where.ToString()
end if

The problem is that the value of CType(Select_ ,TableCommand).where.ToString() is always null.

Is there anything wrong with the code or is there any alternative to do this?

Thanks in advance,
Abhilash
View profile  Send private message
DonB
Posted: 07/13/2007, 6:18 PM

The where clause will only exist in the events that deal with fetching data
for the grid. Presumably you are trying to obtain it as you transition to
the other form, long after the where has been discarded (after the select
was executed).

--
DonB

http://www.gotodon.com/ccbth


"worldofabhilash" <worldofabhilash@forum.codecharge> wrote in message
news:84697f99d7a131@news.codecharge.com...
> Hi,
>
> I need to pass the where clause of the the grid to another form. I have
used
> the following code to store the value of the where clause to a session
> variable:
>
> if HttpContext.Current.Session("sqlWhere") = nothing then
> HttpContext.Current.Session.Add("sqlWhere","")
> end if
> if DirectCast(Select_,TableCommand).Where.ToString() <> "" then
> HttpContext.Current.Session("sqlWhere") = CType(Select_
> ,TableCommand).where.ToString()
> end if
>
> The problem is that the value of CType(Select_
,TableCommand).where.ToString()
> is always null.
>
> Is there anything wrong with the code or is there any alternative to do
this?
>
> Thanks in advance,
> Abhilash
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Vasiliy

Posts: 378
Posted: 07/16/2007, 7:11 AM

I use SQL WHERE to run reports from the page.
My approach:
In Grid event "BeforeExecuteSelect" add code:
Dim SelectStr As String = Select_.ToString()
Dim TempLen As Integer = Len(SelectStr)
Dim TempPos As Integer = InStrRev(SelectStr, "WHERE", -1, 1)
If TempPos > 0 Then SelectStr = Right(SelectStr, TempLen - (TempPos + 6))
If TempPos = 0 Then SelectStr = ""
TempPos = InStr(1, SelectStr, "ORDER BY", 1)
If TempPos > 0 Then SelectStr = Left(SelectStr, TempPos - 1)
System.Web.HttpContext.Current.Session("ReportSQLWhere") = Trim(SelectStr)
_________________
Vasiliy
View profile  Send private message
worldofabhilash

Posts: 3
Posted: 07/16/2007, 11:26 AM

Thanks Vasiliy... That worked for me :-)
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.