连动也OK了...
程序代码:
Protected Sub depNo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles depNo.SelectedIndexChanged
Dim DepNo As String = sender.SelectedValue : DepNo = Mid(DepNo, 1, 4)
Dim dbCmdSQL As SqlCommand
Dim mySQL As String
UserNo.Items.Clear() : UserNo.Items.Add(New ListItem(""))
ClassNo.Items.Clear() : ClassNo.Items.Add(New ListItem(""))
Try
mySQL = "SELECT EmployeeNo, EmployeeName FROM tblMstEmployee Where DepartmentNo = '" & DepNo & "' AND Active = 'Y'"
Using mySqlDS = New SqlConnection(ConfigurationManager.ConnectionStrings(strCnnType & "DbBTA").ToString)
dbCmdSQL = New SqlCommand(mySQL, mySqlDS)
mySqlDS.Open()
Using dbDRSQL = dbCmdSQL.ExecuteReader
While dbDRSQL.Read
Dim str As String = dbDRSQL("EmployeeName").ToString & " (" & dbDRSQL("EmployeeNo").ToString & ")"
UserNo.Items.Add(New ListItem(str))
End While
End Using
End Using
mySQL = "SELECT ClassID, SubClassID, FileID FROM tblClassList"
Using mySqlDS = New SqlConnection(ConfigurationManager.ConnectionStrings(strCnnType & "DbBTA").ToString)
dbCmdSQL = New SqlCommand(mySQL, mySqlDS)
mySqlDS.Open()
Using dbDRSQL = dbCmdSQL.ExecuteReader
While dbDRSQL.Read
Dim str As String = GetClassName(0, dbDRSQL("ClassID").ToString, dbDRSQL("SubClassID").ToString, dbDRSQL("FileID").ToString)
ClassNo.Items.Add(New ListItem(str))
End While
End Using
End Using
Catch ex As Exception
Dim strErr As String = "●●● 程式错误讯息如下 ●●●" & "\n\n" & Replace(Replace(Replace(Replace(Trim(ex.ToString()), Chr(10), ""), Chr(13), ""), "\", "\\"), "'", "\'")
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "alert", "alert('" & strErr & "');", True)
End Try
End Sub