Wed Nov 05, 2008 6:29 pm
Dim strConn As String
strConn = ConfigurationSettings.AppSettings("connectionString")
Dim myConn As New SqlConnection(strConn)
Try
Dim strSQL As String
cboEmpList.Items.Clear()
strSQL = "select distinct EId, LName, FName, Mi " & _
" from EmpQualMain " & _
" where BrCode = '" & gBranchCode & "'" & _
" order by Lname, FName"
Dim myCommand As New SqlCommand(strSQL, myConn)
myConn.Open()
Dim myRead As SqlDataReader = myCommand.ExecuteReader
(CommandBehavior.Default)
While myRead.Read
cboEmpList.Items.Add(myRead.GetValue(myRead.GetOrdinal
("LName")) + ", " + myRead.GetValue(myRead.GetOrdinal("FName"))
+ " " + myRead.GetValue(myRead.GetOrdinal("Mi")))
cboEmpList.DataValueField = myRead.GetValue(myRead.GetOrdinal
("EId"))
End While
myRead.Close()
Catch exc1 As Exception
Response.Write(exc1.Message)
Finally
If Not (myConn Is Nothing) Then
If myConn.State = System.Data.ConnectionState.Open Then
myConn.Close()
End If
End Try
Wed Nov 05, 2008 6:32 pm
Dim adapter as New SqlDataAdapter(strSql, connect)
Dim dsResult As System.Data.DataSet
adapter.Fill(dsResult)
cboEmpList.DataSource = dsResult.Tables(0)
cboEmpList.DisplayMember = "employeeName"
cboEmpList.ValueMember = "eid"
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.