lvandevender
asked on
Do i have too many End IF statements in the code
I need to know if I need this many IF statements in this code
If Request.Form("StartDate") <> "" Or Request.Form("EndDate") <> "" Then
If Request.Form("datetype") = "Orders Shipped" Then
scmd.Append(" AND (")
If Request.Form("StartDate") <> "" Then
scmd.Append(" SHIP_DT >= TO_DATE('")
If Request.Form("StartDate") <> "" Then
scmd.Append(Year(Request.F orm("Start Date")))
scmd.Append("/")
scmd.Append(Month(Request. Form("Star tDate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("StartD ate")))
scmd.Append("','yyyy/mm/dd ')")
End If
End If
End If
End If
If Request.Form("StartDate") <> "" Or Request.Form("EndDate") <> "" Then
If Request.Form("datetype") = "Orders Shipped" Then
scmd.Append(" AND (")
If Request.Form("StartDate") <> "" Then
scmd.Append(" SHIP_DT >= TO_DATE('")
If Request.Form("StartDate") <> "" Then
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append("','yyyy/mm/dd
End If
End If
End If
End If
Looks right to me...are you getting an error?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what about this code??
If Request.Form("EndDate") <> "" Then
If Request.Form("StartDate") <> "" Then
scmd.Append(" SHIP_DT <= TO_DATE('")
scmd.Append(Year(Request.F orm("Start Date")))
scmd.Append("/")
scmd.Append(Month(Request. Form("Star tDate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("StartD ate")))
scmd.Append(", yyyy/mm/dd)")
scmd.Append(" AND ")
End If
scmd.Append(" SHIP_DT <= TO_DATE('")
scmd.Append(Year(Request.F orm("EndDa te")))
scmd.Append("/")
scmd.Append(Month(Request. Form("EndD ate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("EndDat e")))
scmd.Append("','yyyy/mm/dd ')")
End If
scmd.Append(") ")
End If
If Request.Form("EndDate") <> "" Then
If Request.Form("StartDate") <> "" Then
scmd.Append(" SHIP_DT <= TO_DATE('")
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append(", yyyy/mm/dd)")
scmd.Append(" AND ")
End If
scmd.Append(" SHIP_DT <= TO_DATE('")
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append("','yyyy/mm/dd
End If
scmd.Append(") ")
End If
ASKER
"I don't see any problem with End If but the "(" don't match the ")" what does not match???
one too many end if's from what i can see
in the second sample that is
Private ReadOnly Property HasStartDate() As Boolean
Get
Dim value As Boolean = ( DateTime.Compare(StartDate ,DateTime. MinValue) > 0)
Return value
End Get
End Property
Private ReadOnly Property HasEndDate() As Boolean
Get
Dim value As Boolean = ( DateTime.Compare(EndDate,D ateTime.Mi nValue) > 0)
Return value
End Get
End Property
Private ReadOnly Property StartDate() As DateTime
Get
Dim value As String = GetItem("StartDate")
Dim dt As DateTime
If value.Length > 0 Then
dt = DateTime.Parse(value)
End If
Return dt
End Get
End Property
Private ReadOnly Property DateType() As String
Get
Return GetItem("datetype")
End Get
End Property
Private ReadOnly Property EndDate() As DateTime
Get
Dim value As String = GetItem("EndDate")
Dim dt As DateTime
If value.Length > 0 Then
dt = DateTime.Parse(value)
End If
Return dt
End Get
End Property
Private Function GetItem(ByVal name As String) As String
Dim value As String = String.Empty
If Not Request.Form(name) Is Nothing Then
value = Request.Form(name)
End If
Return value.Trim()
End Function
' your code
If HasStartDate AndAlso HasEndDate AndAlso DateType = "Orders Shipped" Then
scmd.Append(" AND (")
If HasStartDate Then
'if scmd is StringBuilder
scmd.AppendFormat("SHIP_DT >= TO_DATE('{0}','yyyy/MM/dd' )",StartDa te.ToStrin g("yyyy/MM /dd"))
End If
End If
Get
Dim value As Boolean = ( DateTime.Compare(StartDate
Return value
End Get
End Property
Private ReadOnly Property HasEndDate() As Boolean
Get
Dim value As Boolean = ( DateTime.Compare(EndDate,D
Return value
End Get
End Property
Private ReadOnly Property StartDate() As DateTime
Get
Dim value As String = GetItem("StartDate")
Dim dt As DateTime
If value.Length > 0 Then
dt = DateTime.Parse(value)
End If
Return dt
End Get
End Property
Private ReadOnly Property DateType() As String
Get
Return GetItem("datetype")
End Get
End Property
Private ReadOnly Property EndDate() As DateTime
Get
Dim value As String = GetItem("EndDate")
Dim dt As DateTime
If value.Length > 0 Then
dt = DateTime.Parse(value)
End If
Return dt
End Get
End Property
Private Function GetItem(ByVal name As String) As String
Dim value As String = String.Empty
If Not Request.Form(name) Is Nothing Then
value = Request.Form(name)
End If
Return value.Trim()
End Function
' your code
If HasStartDate AndAlso HasEndDate AndAlso DateType = "Orders Shipped" Then
scmd.Append(" AND (")
If HasStartDate Then
'if scmd is StringBuilder
scmd.AppendFormat("SHIP_DT
End If
End If
If HasDateType AndAlso (HasStartDate OrElse HasEndDate)Then
scmd.Append(" AND (")
If HasStartDate AndAlso HasEndDate Then
scmd.AppendFormat("SHIP_DT >= TO_DATE('{0}','yyyy/MM/dd' ) AND SHIP_DT <= TO_DATE('{1}','yyyy/MM/dd' )",StartDa te.ToStrin g("yyyy/MM /dd"),EndD ate.ToStri ng("yyyy/M M/dd"))
ElseIf HasStartDate Then
scmd.AppendFormat("SHIP_DT >= TO_DATE('{0}','yyyy/MM/dd' )",StartDa te.ToStrin g("yyyy/MM /dd" ))
Else
scmd.AppendFormat("SHIP_DT <= TO_DATE('{0}','yyyy/MM/dd' )",EndDate .ToString( "yyyy/MM/d d" ))
End If
scmd.Append(") ")
End If
scmd.Append(" AND (")
If HasStartDate AndAlso HasEndDate Then
scmd.AppendFormat("SHIP_DT
ElseIf HasStartDate Then
scmd.AppendFormat("SHIP_DT
Else
scmd.AppendFormat("SHIP_DT
End If
scmd.Append(") ")
End If
you really need to use properties to not only make your code readable but easily maintained..
The left parentheses don't match the right parentheses. I'm not sure what your basic problem is. You asked about "End If"s and that has been answered.
Are you getting some error or exception? What is it you are asking?
Are you getting some error or exception? What is it you are asking?
ASKER
My problem is that I created a data grid for a web form and when i view it in the browser it will not come up. the link buttons are there and the images and label but no datagrid. I am trying to figure out if my selection criteria is wrong . There is a page that is opened before this page that controls what data comes up on the datagrid.
ASKER
i can give you the entire code if you want but its long ha ha but it may help here it is.. its saved at pipelineviewresults.aspx.v b so i guess this is vb.net and asp.net
Imports System.Data
Imports System.Data.Oledb
Imports System.Text
Public Class PipelineViewResults
Inherits System.Web.UI.Page
Public Criteria
Public ocriteria
Public Codes
Public OpCo
Public PO
Public obox
Public CodeCriteria
Public StartDate
Public EndDate
Public Datetype
Protected Property [SortField]() As String
Get
Return CStr(ViewState("SortField" ))
End Get
Set(ByVal Value As String)
ViewState("SortField") = Value
End Set
End Property
Protected Property [Direction]() As String
Get
Return CStr(Viewstate("Direction" ))
End Get
Set(ByVal Value As String)
ViewState("Direction") = Value
End Set
End Property
Private reader As OleDbDataReader
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg erStepThro ugh()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls. Label
Protected WithEvents Button1 As System.Web.UI.HtmlControls .HtmlInput Button
Protected WithEvents Button2 As System.Web.UI.HtmlControls .HtmlInput Button
Protected WithEvents button3 As System.Web.UI.HtmlControls .HtmlInput Button
Protected WithEvents button4 As System.Web.UI.HtmlControls .HtmlInput Button
Protected WithEvents DataGrid1 As System.Web.UI.WebControls. DataGrid
Protected WithEvents Image1 As System.Web.UI.WebControls. Image
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara tion As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Criteria = Request.Form("Criteria")
obox = Request.Form("obox")
OpCo = Request.Form("operatingcom pany")
PO = Request.Form("po")
CodeCriteria = Request.Form("CodeCriteria ")
ocriteria = Request.Form("ocriteria")
datetype = Request.Form("datetype")
StartDate = Request.Form("StartDate")
EndDate = Request.Form("EndDate")
If Request.Form("Codes") = "" Then
Codes = 1
Else
If (IsNumeric(Left(Request.Fo rm("Codes" ), InStr(1, Request.Form("Codes"), ".")))) Then
Codes = CLng(Left(Request.Form("Co des"), InStr(1, Request.Form("Codes"), ".")))
Else
Codes = Left(Request.Form("Codes") , InStr(1, Request.Form("Codes"), ".") - 1)
End If
End If
If (IsNumeric(Request.Form("o peratingco mpany"))) Then
OpCo = CLng(Request.Form("operati ngcompany" ))
Else
OpCo = Request.Form("operatingcom pany")
End If
End Sub
Private Sub DataGrid1_SortCommand(ByVa l source As Object, ByVal e As System.Web.UI.WebControls. DataGridSo rtCommandE ventArgs) Handles DataGrid1.SortCommand
If SortField = e.SortExpression() And Direction = " asc" Then
Direction = " desc"
Else
Direction = " asc"
End If
SortField = e.SortExpression()
getinfo()
End Sub
Public Sub getinfo()
Const slen = 250, loops = 100
Dim scmd As New StringBuilder
Dim sSQL As String
Dim strConnection As String = "Provider=msdaora ;DataSource=LISPROD;User id=Pipeuser;Password=Web"
Dim con As New OleDbConnection(strConnect ion)
Const sSEL1 = "SELECT DISTINCT a.PO_NUM, a.DEPT,a.DCNAME,a.LEGVENDO R, a.SHIP_DT, a.CANCEL_DT, a.STATUS, b.es_bol, sum(b.ed_piece), "
Const sSEL2 = " FROM PIPELINE.VPV001PO a, maxmain.v_exptpo b "
Const sSEL3 = " WHERE Rtrim(a.PO_NUM) = b.ed_pono"
Const OrderBy = " Order By "
Const Quote = "'"
scmd.Append(sSEL1)
scmd.Append(sSEL2)
scmd.Append(sSEL3)
Select Case CodeCriteria
Case "GMM"
scmd.Append("and gmm_num = ")
scmd.Append(Codes)
Case "DMM"
scmd.Append("and dmm_num = ")
scmd.Append(Codes)
Case "Buyer"
scmd.Append("and buyer_cd = ")
scmd.Append(Codes)
Case "Dept"
If Len(Codes) = 1 Then
Codes = "00" & Codes
ElseIf Len(Codes) = 2 Then
Codes = "0" & Codes
End If
scmd.Append(" AND DEPT = ")
scmd.Append(Codes)
End Select
If OpCo <> "All" Then
scmd.Append(" AND OPCO = ")
scmd.Append(OpCo)
End If
If Request.Form("po") <> "" Then
scmd.Append(" AND PO_NUM = '")
scmd.Append(PO)
End If
If Request.Form("obox") <> "" Then
Select Case Criteria
Case "Legacy Vendor"
scmd.Append(" AND LEGVENDOR LIKE '%")
scmd.Append(obox)
scmd.Append("%'")
Case "Corporate Vendor"
scmd.Append(" AND CORPVENDOR LIKE '%")
scmd.Append(obox)
scmd.Append("%'")
Case "Division Vendor"
scmd.Append(" AND DIVVENDOR LIKE '%")
scmd.Append(obox)
scmd.Append("%'")
Case "Outbound Manifest"
scmd.Append("select po_num from tpv014manx where manfst_num = ")
scmd.Append(obox)
scmd.Append(")")
Case "BOL"
scmd.Append(" AND BOL = '")
scmd.Append(obox)
scmd.Append("'")
Case "Buying Division"
scmd.Append(" AND DMM_NUM = '")
scmd.Append(obox)
scmd.Append("'")
End Select
End If
If Request.Form("StartDate") <> "" Or Request.Form("EndDate") <> "" Then
If Request.Form("datetype") = "Orders Shipped" Then
scmd.Append(" AND (")
If Request.Form("StartDate") <> "" Then
scmd.Append(" SHIP_DT >= TO_DATE('")
If Request.Form("StartDate") <> "" Then
scmd.Append(Year(Request.F orm("Start Date")))
scmd.Append("/")
scmd.Append(Month(Request. Form("Star tDate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("StartD ate")))
scmd.Append("','yyyy/mm/dd ')")
End If
End If
If Request.Form("EndDate") <> "" Then
If Request.Form("StartDate") <> "" Then
scmd.Append(" SHIP_DT <= TO_DATE('")
scmd.Append(Year(Request.F orm("Start Date")))
scmd.Append("/")
scmd.Append(Month(Request. Form("Star tDate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("StartD ate")))
scmd.Append(", yyyy/mm/dd)")
scmd.Append(" AND ")
End If
scmd.Append(" SHIP_DT <= TO_DATE('")
scmd.Append(Year(Request.F orm("EndDa te")))
scmd.Append("/")
scmd.Append(Month(Request. Form("EndD ate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("EndDat e")))
scmd.Append("','yyyy/mm/dd ')")
End If
scmd.Append(") ")
End If
If Request.Form("datetype") = "Orders Canceled" Then
scmd.Append(" AND (")
If Request.Form("StartDate") <> "" Then
scmd.Append("CANCEL_DT >= TO_DATE('")
scmd.Append(Year(Request.F orm("Start Date")))
scmd.Append("/")
scmd.Append(Month(Request. Form("Star tDate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("StartD ate")))
scmd.Append("','yyyy/mm/dd ')")
End If
If Request.Form("EndDate") <> "" Then
If Request.Form("StartDate") <> "" Then
scmd.Append(" AND ")
scmd.Append(Year(Request.F orm("Start Date")))
scmd.Append("/")
scmd.Append(Month(Request. Form("Star tDate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("StartD ate")))
scmd.Append(", yyyy/mm/dd)")
scmd.Append(" AND ")
End If
scmd.Append("CANCEL_DT <= TO_DATE('")
scmd.Append(Year(Request.F orm("EndDa te")))
scmd.Append("/")
scmd.Append(Month(Request. Form("EndD ate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("EndDat e")))
scmd.Append("','yyyy/mm/dd ')")
End If
scmd.Append(") ")
End If
If Request.Form("datetype") = "Orders Received" Then
scmd.Append(" AND (")
If Request.Form("StartDate") <> "" Then
scmd.Append("DELIVER_DT >= TO_DATE('")
scmd.Append(Year(Request.F orm("Start Date")))
scmd.Append("/")
scmd.Append(Month(Request. Form("Star tDate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("StartD ate")))
scmd.Append("','yyyy/mm/dd ')")
End If
If Request.Form("EndDate") <> "" Then
If Request.Form("StartDate") <> "" Then
scmd.Append(" AND ")
End If
scmd.Append("DELIVER_DT <= TO_DATE('")
scmd.Append(Year(Request.F orm("EndDa te")))
scmd.Append("/")
scmd.Append(Month(Request. Form("EndD ate")))
scmd.Append("/")
scmd.Append(Day(Request.Fo rm("EndDat e")))
scmd.Append("','yyyy/mm/dd ')")
End If
scmd.Append(") ")
End If
End If
If Not SortField = String.Empty Then
scmd.Append(OrderBy)
scmd.Append(SortField)
scmd.Append(Direction)
End If
sSQL = scmd.ToString()
'Response.Write(sSQL)
Dim cmd As New OleDbCommand(sSQL, con)
con.Open()
reader = cmd.ExecuteReader(CommandB ehavior.Cl oseConnect ion)
DataGrid1.DataSource = reader
DataGrid1.DataBind()
con.Close()
End Sub
Private Sub OleDbConnection1_InfoMessa ge(ByVal sender As System.Object, ByVal e As System.Data.OleDb.OleDbInf oMessageEv entArgs)
End Sub
Private Sub DataGrid1_SelectedIndexCha nged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexCha nged
End Sub
End Class
Imports System.Data
Imports System.Data.Oledb
Imports System.Text
Public Class PipelineViewResults
Inherits System.Web.UI.Page
Public Criteria
Public ocriteria
Public Codes
Public OpCo
Public PO
Public obox
Public CodeCriteria
Public StartDate
Public EndDate
Public Datetype
Protected Property [SortField]() As String
Get
Return CStr(ViewState("SortField"
End Get
Set(ByVal Value As String)
ViewState("SortField") = Value
End Set
End Property
Protected Property [Direction]() As String
Get
Return CStr(Viewstate("Direction"
End Get
Set(ByVal Value As String)
ViewState("Direction") = Value
End Set
End Property
Private reader As OleDbDataReader
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.
Protected WithEvents Button1 As System.Web.UI.HtmlControls
Protected WithEvents Button2 As System.Web.UI.HtmlControls
Protected WithEvents button3 As System.Web.UI.HtmlControls
Protected WithEvents button4 As System.Web.UI.HtmlControls
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.
Protected WithEvents Image1 As System.Web.UI.WebControls.
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclara
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Criteria = Request.Form("Criteria")
obox = Request.Form("obox")
OpCo = Request.Form("operatingcom
PO = Request.Form("po")
CodeCriteria = Request.Form("CodeCriteria
ocriteria = Request.Form("ocriteria")
datetype = Request.Form("datetype")
StartDate = Request.Form("StartDate")
EndDate = Request.Form("EndDate")
If Request.Form("Codes") = "" Then
Codes = 1
Else
If (IsNumeric(Left(Request.Fo
Codes = CLng(Left(Request.Form("Co
Else
Codes = Left(Request.Form("Codes")
End If
End If
If (IsNumeric(Request.Form("o
OpCo = CLng(Request.Form("operati
Else
OpCo = Request.Form("operatingcom
End If
End Sub
Private Sub DataGrid1_SortCommand(ByVa
If SortField = e.SortExpression() And Direction = " asc" Then
Direction = " desc"
Else
Direction = " asc"
End If
SortField = e.SortExpression()
getinfo()
End Sub
Public Sub getinfo()
Const slen = 250, loops = 100
Dim scmd As New StringBuilder
Dim sSQL As String
Dim strConnection As String = "Provider=msdaora ;DataSource=LISPROD;User id=Pipeuser;Password=Web"
Dim con As New OleDbConnection(strConnect
Const sSEL1 = "SELECT DISTINCT a.PO_NUM, a.DEPT,a.DCNAME,a.LEGVENDO
Const sSEL2 = " FROM PIPELINE.VPV001PO a, maxmain.v_exptpo b "
Const sSEL3 = " WHERE Rtrim(a.PO_NUM) = b.ed_pono"
Const OrderBy = " Order By "
Const Quote = "'"
scmd.Append(sSEL1)
scmd.Append(sSEL2)
scmd.Append(sSEL3)
Select Case CodeCriteria
Case "GMM"
scmd.Append("and gmm_num = ")
scmd.Append(Codes)
Case "DMM"
scmd.Append("and dmm_num = ")
scmd.Append(Codes)
Case "Buyer"
scmd.Append("and buyer_cd = ")
scmd.Append(Codes)
Case "Dept"
If Len(Codes) = 1 Then
Codes = "00" & Codes
ElseIf Len(Codes) = 2 Then
Codes = "0" & Codes
End If
scmd.Append(" AND DEPT = ")
scmd.Append(Codes)
End Select
If OpCo <> "All" Then
scmd.Append(" AND OPCO = ")
scmd.Append(OpCo)
End If
If Request.Form("po") <> "" Then
scmd.Append(" AND PO_NUM = '")
scmd.Append(PO)
End If
If Request.Form("obox") <> "" Then
Select Case Criteria
Case "Legacy Vendor"
scmd.Append(" AND LEGVENDOR LIKE '%")
scmd.Append(obox)
scmd.Append("%'")
Case "Corporate Vendor"
scmd.Append(" AND CORPVENDOR LIKE '%")
scmd.Append(obox)
scmd.Append("%'")
Case "Division Vendor"
scmd.Append(" AND DIVVENDOR LIKE '%")
scmd.Append(obox)
scmd.Append("%'")
Case "Outbound Manifest"
scmd.Append("select po_num from tpv014manx where manfst_num = ")
scmd.Append(obox)
scmd.Append(")")
Case "BOL"
scmd.Append(" AND BOL = '")
scmd.Append(obox)
scmd.Append("'")
Case "Buying Division"
scmd.Append(" AND DMM_NUM = '")
scmd.Append(obox)
scmd.Append("'")
End Select
End If
If Request.Form("StartDate") <> "" Or Request.Form("EndDate") <> "" Then
If Request.Form("datetype") = "Orders Shipped" Then
scmd.Append(" AND (")
If Request.Form("StartDate") <> "" Then
scmd.Append(" SHIP_DT >= TO_DATE('")
If Request.Form("StartDate") <> "" Then
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append("','yyyy/mm/dd
End If
End If
If Request.Form("EndDate") <> "" Then
If Request.Form("StartDate") <> "" Then
scmd.Append(" SHIP_DT <= TO_DATE('")
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append(", yyyy/mm/dd)")
scmd.Append(" AND ")
End If
scmd.Append(" SHIP_DT <= TO_DATE('")
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append("','yyyy/mm/dd
End If
scmd.Append(") ")
End If
If Request.Form("datetype") = "Orders Canceled" Then
scmd.Append(" AND (")
If Request.Form("StartDate") <> "" Then
scmd.Append("CANCEL_DT >= TO_DATE('")
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append("','yyyy/mm/dd
End If
If Request.Form("EndDate") <> "" Then
If Request.Form("StartDate") <> "" Then
scmd.Append(" AND ")
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append(", yyyy/mm/dd)")
scmd.Append(" AND ")
End If
scmd.Append("CANCEL_DT <= TO_DATE('")
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append("','yyyy/mm/dd
End If
scmd.Append(") ")
End If
If Request.Form("datetype") = "Orders Received" Then
scmd.Append(" AND (")
If Request.Form("StartDate") <> "" Then
scmd.Append("DELIVER_DT >= TO_DATE('")
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append("','yyyy/mm/dd
End If
If Request.Form("EndDate") <> "" Then
If Request.Form("StartDate") <> "" Then
scmd.Append(" AND ")
End If
scmd.Append("DELIVER_DT <= TO_DATE('")
scmd.Append(Year(Request.F
scmd.Append("/")
scmd.Append(Month(Request.
scmd.Append("/")
scmd.Append(Day(Request.Fo
scmd.Append("','yyyy/mm/dd
End If
scmd.Append(") ")
End If
End If
If Not SortField = String.Empty Then
scmd.Append(OrderBy)
scmd.Append(SortField)
scmd.Append(Direction)
End If
sSQL = scmd.ToString()
'Response.Write(sSQL)
Dim cmd As New OleDbCommand(sSQL, con)
con.Open()
reader = cmd.ExecuteReader(CommandB
DataGrid1.DataSource = reader
DataGrid1.DataBind()
con.Close()
End Sub
Private Sub OleDbConnection1_InfoMessa
End Sub
Private Sub DataGrid1_SelectedIndexCha
End Sub
End Class
ASKER