G
Guest
I used the following two routines to fil a drop-down box in a VS 2003 web
project
What do I need to do to make these work with list controls in 2005 Windows
Projects?
========================================
Private Sub FillWithDepts(ByVal strStartDate As String)
Dim drDepts As SqlClient.SqlDataReader
drDepts = AppointmentsBLL.GetDeptNames(strStartDate)
Me.cmbSourceList.Items.Clear()
Me.cmbSourceList.Items.Add(New ListItem("", ""))
Do While drDepts.Read
Me.cmbSourceList.Items.Add(New ListItem(drDepts("Dept")))
Loop
End Sub
Public Shared Function GetDeptNames(ByVal strStartDate As String) As
SqlDataReader
'This function gets the Dept names from the most recent appointment
table
'with related date
'functions as a data reader
Dim drDepts As SqlDataReader
Dim conMembers As SqlConnection = GetMembershipConnection()
Dim strSQL As String
strSQL = "SELECT DISTINCT Dept " _
& "FROM tbl_Appt WHERE ApptDate =@StartDate Order by Dept "
Dim cmdGetDepts As New SqlCommand(strSQL, conMembers)
cmdGetDepts.CommandType = CommandType.Text
Dim pStartDt As New SqlParameter("@StartDate", SqlDbType.VarChar)
With cmdGetDepts
pStartDt.Direction = ParameterDirection.Input
pStartDt.Value = strStartDate
.Parameters.Add(pStartDt)
End With
conMembers.Open()
drDepts = cmdGetDepts.ExecuteReader(CommandBehavior.CloseConnection)
Return drDepts
End Function
project
What do I need to do to make these work with list controls in 2005 Windows
Projects?
========================================
Private Sub FillWithDepts(ByVal strStartDate As String)
Dim drDepts As SqlClient.SqlDataReader
drDepts = AppointmentsBLL.GetDeptNames(strStartDate)
Me.cmbSourceList.Items.Clear()
Me.cmbSourceList.Items.Add(New ListItem("", ""))
Do While drDepts.Read
Me.cmbSourceList.Items.Add(New ListItem(drDepts("Dept")))
Loop
End Sub
Public Shared Function GetDeptNames(ByVal strStartDate As String) As
SqlDataReader
'This function gets the Dept names from the most recent appointment
table
'with related date
'functions as a data reader
Dim drDepts As SqlDataReader
Dim conMembers As SqlConnection = GetMembershipConnection()
Dim strSQL As String
strSQL = "SELECT DISTINCT Dept " _
& "FROM tbl_Appt WHERE ApptDate =@StartDate Order by Dept "
Dim cmdGetDepts As New SqlCommand(strSQL, conMembers)
cmdGetDepts.CommandType = CommandType.Text
Dim pStartDt As New SqlParameter("@StartDate", SqlDbType.VarChar)
With cmdGetDepts
pStartDt.Direction = ParameterDirection.Input
pStartDt.Value = strStartDate
.Parameters.Add(pStartDt)
End With
conMembers.Open()
drDepts = cmdGetDepts.ExecuteReader(CommandBehavior.CloseConnection)
Return drDepts
End Function