L
Leanne
I have a VB6 project that I'm migrating to VB 2008. There is a routine in the
old project to LoadArrays. By passing the proc name and arrayName to load I
can set up a series of calls at application load and have these arrays
available throughout the application (Info is used in many areas to populated
controls) The old routine makes use of Getrows. Example: arraydef =
rs1.GetRows I am not finding an equivalent in 2008. I have written new code
beload to load data into a dictionary. I have approximately 5 more to do. I
would think there would be a way that I could write a single routine to
handle all 5 but I'm not if this is possible in this version and not sure how
to approach. The dicitionary defs will not be the same for all of them (of
String, Int16). Any help would be appreciated. I'm just learning and have
spent a lot of time just getting this far. Thanks in advance.
Public Sub LoadAPCodeArrayList(ByVal strsqlcmd As String, ByVal APCodeList
As Generic.Dictionary(Of String, Int16))
Dim cn As SqlConnection
Dim cmd As SqlCommand
Dim msqlDataReader As SqlDataReader
Dim i As Integer
'Establish connection
cn = New SqlConnection()
cn.ConnectionString = GetCnnString()
cn.Open()
'Set up sqlcommand object
cmd = New SqlCommand(strsqlcmd, cn)
'Execute command
msqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult)
If msqlDataReader.HasRows Then
With msqlDataReader
While .Read()
APCodeList.Add(msqlDataReader.Item(0).ToString,
CShort(msqlDataReader.Item(1)))
End While
End With
End If
If Not IsNothing(msqlDataReader) Then
msqlDataReader.Close()
msqlDataReader = Nothing
End If
cn.Close()
End Sub
'--Call from form
strSQL = "select apcodes, domintl from AP_Codes"
LoadAPCodeArrayList(strSQL, APCodeList)
old project to LoadArrays. By passing the proc name and arrayName to load I
can set up a series of calls at application load and have these arrays
available throughout the application (Info is used in many areas to populated
controls) The old routine makes use of Getrows. Example: arraydef =
rs1.GetRows I am not finding an equivalent in 2008. I have written new code
beload to load data into a dictionary. I have approximately 5 more to do. I
would think there would be a way that I could write a single routine to
handle all 5 but I'm not if this is possible in this version and not sure how
to approach. The dicitionary defs will not be the same for all of them (of
String, Int16). Any help would be appreciated. I'm just learning and have
spent a lot of time just getting this far. Thanks in advance.
Public Sub LoadAPCodeArrayList(ByVal strsqlcmd As String, ByVal APCodeList
As Generic.Dictionary(Of String, Int16))
Dim cn As SqlConnection
Dim cmd As SqlCommand
Dim msqlDataReader As SqlDataReader
Dim i As Integer
'Establish connection
cn = New SqlConnection()
cn.ConnectionString = GetCnnString()
cn.Open()
'Set up sqlcommand object
cmd = New SqlCommand(strsqlcmd, cn)
'Execute command
msqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult)
If msqlDataReader.HasRows Then
With msqlDataReader
While .Read()
APCodeList.Add(msqlDataReader.Item(0).ToString,
CShort(msqlDataReader.Item(1)))
End While
End With
End If
If Not IsNothing(msqlDataReader) Then
msqlDataReader.Close()
msqlDataReader = Nothing
End If
cn.Close()
End Sub
'--Call from form
strSQL = "select apcodes, domintl from AP_Codes"
LoadAPCodeArrayList(strSQL, APCodeList)