例子:
Private Sub SCList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles SCListZL.SelectedIndexChanged
If Trim(Me.SCListZL.SelectedValue) = "铁" Then
Dim chj, DW, JS, r, t As String
Dim objdataset As New DataSet
Dim objconn As New OleDbConnection
Dim oleDbAdapter1 As OleDbDataAdapter
Dim connstr As String, xt As String, s As String
Dim objdccommand As OleDbCommand
DW = Trim(Me.SCListCJ.SelectedValue)
JS = Trim(Session("JiShu"))
chj = "(主任审核 = '通过' and 科长审核 = '通过') and " + "(" + "车间 = '" + DW + "')"
connstr = Trim(PLXTLJM)
If connstr <> "" Then
objconn.ConnectionString = connstr
objconn.Open()
xt = "20"
If chj = "" Then
s = "select top " + Trim(xt) + " ID,车间,车间审核,科长审核,生产品种 from tbPeiLiao ORDER BY 日期 DESC"
'时间,
Else
s = "select top " + Trim(xt) + " ID,车间,车间审核,科长审核,生产品种 from tbPeiLiao where " + Trim(chj) + " ORDER BY 日期 DESC" '时间
End If
oleDbAdapter1 = New OleDbDataAdapter(s, objconn)
oleDbAdapter1.Fill(objdataset)
Me.DataGridFSQ.DataSource = objdataset
Me.DataGridFSQ.DataBind()
objdataset.Clear()
objdataset.Dispose()
oleDbAdapter1.Dispose()
objconn.Close()
objconn.Dispose()
End If
End If
If Trim(Me.SCListZL.SelectedValue) = "铁" Then
Dim chj, DW, JS, r, t As String
Dim objdataset As New DataSet
Dim objconn As New OleDbConnection
Dim oleDbAdapter1 As OleDbDataAdapter
Dim connstr As String, xt As String, s As String
Dim objdccommand As OleDbCommand
DW = Trim(Me.SCListCJ.SelectedValue)
JS = Trim(Session("JiShu"))
chj = "(主任审核 = '通过' and 科长审核 = '通过') and " + "(" + "车间 = '" + DW + "')"
connstr = Trim(PLXTLJM)
If connstr <> "" Then
objconn.ConnectionString = connstr
objconn.Open()
xt = "20"
If chj = "" Then
s = "select top " + Trim(xt) + " ID,车间,车间审核,科长审核,生产品种 from tbPLMnFe ORDER BY 日期 DESC"
'时间,
Else
s = "select top " + Trim(xt) + " ID,车间,车间审核,科长审核,生产品种 from tbPLMnFe where " + Trim(chj) + " ORDER BY 日期 DESC" '时间
End If
oleDbAdapter1 = New OleDbDataAdapter(s, objconn)
oleDbAdapter1.Fill(objdataset)
Me.DataGridFSQ.DataSource = objdataset
Me.DataGridFSQ.DataBind()
objdataset.Clear()
objdataset.Dispose()
oleDbAdapter1.Dispose()
objconn.Close()
objconn.Dispose()
End If
End If
End Sub