Items.AddRange throws exception if used more than once
Hello,
I'm having an issue with updating a couple list boxes in the form load procedure. I have an array created from a MySQL database, and when I try to add that array to more than one ListBox, I get:
A first chance exception of type 'System.ArgumentNullException' occurred in System.Windows.Forms.dll
Public Sub UpdateNames(ByRef Names() As String)
Dim sql As String = "SELECT Name FROM users"
Dim cmd As MySqlCommand = New MySqlCommand(sql, Login.SQLConnection)
Dim reader As MySqlDataReader = cmd.ExecuteReader()
Do While reader.Read()
Static i As Integer = 1
ReDim Preserve Names(i)
Names(i - 1) = reader.GetString(0)
i += 1
Loop
reader.Close()
End Sub
Thanks in advance for your help!
2
Contributors
1
Reply
4 Days
Discussion Span
1 Year Ago
Last Updated
2
Views
Related Article:VB.NET - Null Reference Exception was unhandled
is a solved VB.NET discussion thread by STP_Captain_Slo that has 6 replies, was last updated 2 years ago and has been tagged with the keywords: exception, null, reference, vb.net.