Array Issue

HeavenCore

Well-known member
Joined
Apr 10, 2007
Messages
77
Location
Bolton, England
Programming Experience
1-3
Hi, i have a dynamic array issue, i am readin in a record set into an array, but i am getting an error when assigning a value to the array

"Object reference not set to an instance of an object." so i am guessing i need to use 'new' or something, code as follows:

VB.NET:
            Dim weeks() As String
            Dim i As Integer = 0
            'get an array of enclosure
            Dim SQLstatement As New SqlClient.SqlCommand("SELECT     WeekGrid_fk " + _
            "FROM m2mWeekLinks " + _
            "WHERE     Enclosure_fk = @EnclosureID", theDatabase)
            SQLstatement.Parameters.AddWithValue("EnclosureID", EnclosureidLabel1.Text)
            Dim QueryResults As SqlClient.SqlDataReader = SQLstatement.ExecuteReader()
            Do While QueryResults.Read()
                Try
                    weeks(i) = QueryResults("WeekGrid_fk")
                    i = i + 1
                Catch ex As Exception 'just catch dbNull etc

                End Try
            Loop
 
Back
Top