M
Mel
I have a web page where the user enters up to 2 inputs and then clicks
the Submit to run the report. On Submit_Click I want to create the
SQL string, based on their inputs, and pass that SQL string to a new
window which will show the report results. How do I create the SQL
string and open the results in a new window?
Here is my code so far, however, it does not open in new window
(Using Asp.net 2.0, Visual Basic.NET, Visual Studio 2005 Pro, WinXP SP
2):
Protected Sub cmdSubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim strRecInv As String
If Trim(txtItem.Text.ToString) = "" And
Trim(txtItemDesc.Text.ToString) = "" Then
Exit Sub
End If
strRecInv = "SELECT [Whs],[Item],[Item Desc],[Qty Available] FROM
[vWhsItemAvailabilty] WHERE ([Whs Desc] <> '')"
If txtItem.Text.ToString <> "" Then
strRecInv = strRecInv & " AND ([Item] LIKE '%" &
txtItem.Text.ToString & "%')"
End If
If txtItemDesc.Text.ToString <> "" Then
strRecInv = strRecInv & " AND ([Item Desc] LIKE '%" &
txtItemDesc.Text.ToString & "%')"
End If
Session("SQLQuery") = strRecInv & " ORDER BY [Whs],[Item Desc]"
Response.Redirect("~/trackresults.aspx") 'This cannot be used to open
in new window. Other ideas?
End Sub
'TrackResults.aspx Page_Load
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
'by passing the SQL String to this page I can use this same page to
show any report results from the Sales database on SQLServer01.
If Session("SQLQuery") Is Nothing Then
Else
Dim conInv As New
SqlConnection("server=SQLServer01;database=Sales;Integrated
Security=SSPI")
Dim comInv As New SqlCommand(Session("SQLQuery"), conInv)
'open database and show results in GridView
conInv.Open()
gvResults.DataSource = comInv.ExecuteReader
gvResults.DataBind()
conInv.Close()
Session("SQLQuery") = Nothing
End If
End Sub
the Submit to run the report. On Submit_Click I want to create the
SQL string, based on their inputs, and pass that SQL string to a new
window which will show the report results. How do I create the SQL
string and open the results in a new window?
Here is my code so far, however, it does not open in new window
(Using Asp.net 2.0, Visual Basic.NET, Visual Studio 2005 Pro, WinXP SP
2):
Protected Sub cmdSubmit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim strRecInv As String
If Trim(txtItem.Text.ToString) = "" And
Trim(txtItemDesc.Text.ToString) = "" Then
Exit Sub
End If
strRecInv = "SELECT [Whs],[Item],[Item Desc],[Qty Available] FROM
[vWhsItemAvailabilty] WHERE ([Whs Desc] <> '')"
If txtItem.Text.ToString <> "" Then
strRecInv = strRecInv & " AND ([Item] LIKE '%" &
txtItem.Text.ToString & "%')"
End If
If txtItemDesc.Text.ToString <> "" Then
strRecInv = strRecInv & " AND ([Item Desc] LIKE '%" &
txtItemDesc.Text.ToString & "%')"
End If
Session("SQLQuery") = strRecInv & " ORDER BY [Whs],[Item Desc]"
Response.Redirect("~/trackresults.aspx") 'This cannot be used to open
in new window. Other ideas?
End Sub
'TrackResults.aspx Page_Load
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
'by passing the SQL String to this page I can use this same page to
show any report results from the Sales database on SQLServer01.
If Session("SQLQuery") Is Nothing Then
Else
Dim conInv As New
SqlConnection("server=SQLServer01;database=Sales;Integrated
Security=SSPI")
Dim comInv As New SqlCommand(Session("SQLQuery"), conInv)
'open database and show results in GridView
conInv.Open()
gvResults.DataSource = comInv.ExecuteReader
gvResults.DataBind()
conInv.Close()
Session("SQLQuery") = Nothing
End If
End Sub