kingesk
10-26-2006, 08:08 AM
I used to have some code in a VB 6 application to send the whole Select statement using .SQLQueryString to Crystal Reports (not just parameters) but I don't see this option in ASP.Net. Is there another way to do this in ASP.Net/VB.Net?
VB6:
' vb 6 works
Set application = CreateObject("crystalruntime.application")
Set Report = application.OpenReport(mstrReportName)
Report.SQLQueryString = strSQL
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
CRViewer91.Refresh
I was trying this in ASP.Net but I'm getting an error. I'm not sure that .SelectionFormula is equivalent to .SQLQueryString. It just says Error in Formaul and shows the Select Statement.
' .Net not working
Me.CrystalReportViewer1.SelectionFormula = strSQL
Me.CrystalReportViewer1.ReportSource = strReportPath
Me.CrystalReportViewer1.RefreshReport()
Here's the code to build my Select Statement
Dim strSearchPart As String = CType(Me.Session("SearchPart"), String)
Dim strSearchDesc As String = CType(Me.Session("SearchDesc"), String)
Dim strSearchKeyWords As String = CType(Me.Session("SearchKeyWords"), String)
Dim strSearchProdCodes As String = CType(Me.Session("SearchProdCodes"), String)
Dim strWhere As String
If Not strSearchPart = "" Then
strWhere=" PartNumber Like '%" & strSearchPart & "%' "
End IF
If Not strSearchDesc = "" Then
If Not strWhere = "" Then
strWhere = strWhere & " And "
End If
strWhere = strWhere & " Description Like '%" & strSearchDesc & "%' "
End IF
If Not strSearchKeyWords = "" Then
If Not strWhere = "" Then
strWhere = strWhere & " And "
End If
strWhere= strWhere & " KeyWordSearch Like '%" & strSearchKeyWords & "%' "
End IF
If Not strSearchProdCodes = "" Then
If Not strWhere = "" Then
strWhere = strWhere & " And "
End If
strWhere = strWhere & " ProdCode Like '%" & strSearchProdCodes & "%' "
End IF
If Not strWhere = "" Then
strWhere = " Where " & strWhere
End IF
Dim strSQL As String
If strWhere ="" Then
strSQL = "SELECT * FROM tWebInfo ORDER BY PartNumber"
Else
strSQL = "SELECT * FROM tWebInfo " & strWhere & " ORDER BY PartNumber"
End IF
' .Net not working
Me.CrystalReportViewer1.SelectionFormula = strSQL
Me.CrystalReportViewer1.ReportSource = strReportPath
Me.CrystalReportViewer1.RefreshReport()
_
VB6:
' vb 6 works
Set application = CreateObject("crystalruntime.application")
Set Report = application.OpenReport(mstrReportName)
Report.SQLQueryString = strSQL
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
CRViewer91.Refresh
I was trying this in ASP.Net but I'm getting an error. I'm not sure that .SelectionFormula is equivalent to .SQLQueryString. It just says Error in Formaul and shows the Select Statement.
' .Net not working
Me.CrystalReportViewer1.SelectionFormula = strSQL
Me.CrystalReportViewer1.ReportSource = strReportPath
Me.CrystalReportViewer1.RefreshReport()
Here's the code to build my Select Statement
Dim strSearchPart As String = CType(Me.Session("SearchPart"), String)
Dim strSearchDesc As String = CType(Me.Session("SearchDesc"), String)
Dim strSearchKeyWords As String = CType(Me.Session("SearchKeyWords"), String)
Dim strSearchProdCodes As String = CType(Me.Session("SearchProdCodes"), String)
Dim strWhere As String
If Not strSearchPart = "" Then
strWhere=" PartNumber Like '%" & strSearchPart & "%' "
End IF
If Not strSearchDesc = "" Then
If Not strWhere = "" Then
strWhere = strWhere & " And "
End If
strWhere = strWhere & " Description Like '%" & strSearchDesc & "%' "
End IF
If Not strSearchKeyWords = "" Then
If Not strWhere = "" Then
strWhere = strWhere & " And "
End If
strWhere= strWhere & " KeyWordSearch Like '%" & strSearchKeyWords & "%' "
End IF
If Not strSearchProdCodes = "" Then
If Not strWhere = "" Then
strWhere = strWhere & " And "
End If
strWhere = strWhere & " ProdCode Like '%" & strSearchProdCodes & "%' "
End IF
If Not strWhere = "" Then
strWhere = " Where " & strWhere
End IF
Dim strSQL As String
If strWhere ="" Then
strSQL = "SELECT * FROM tWebInfo ORDER BY PartNumber"
Else
strSQL = "SELECT * FROM tWebInfo " & strWhere & " ORDER BY PartNumber"
End IF
' .Net not working
Me.CrystalReportViewer1.SelectionFormula = strSQL
Me.CrystalReportViewer1.ReportSource = strReportPath
Me.CrystalReportViewer1.RefreshReport()
_