Is there a way to store data from a sql data reader values to an array?
this is my code
Dim machines() As Integer
Sub machine_entire()
Try
'getting lines from the database
If conn.State = ConnectionState.Closed Then conn.Open()
With cmd
.Connection = conn
.CommandText = "select machineID from tbl_prod_machine where lineID = '" & lineID & "' order by machineID asc"
End With
dr = cmd.ExecuteReader
If dr.HasRows Then
While dr.Read
machines = {dr.GetInt32(dr.GetOrdinal("machineID"))}
End While
dr.Close()
End If
dr.Close()
Catch ex As DataException
MessageBox.Show(ex.Message, ex.GetType.ToString)
Catch ex As SqlException
MessageBox.Show("Sql Server Error # " & ex.Number & ": " & ex.GetType.ToString)
End Try
End Sub
thank you! for the help
machines = {dr.GetInt32(dr.GetOrdinal("machineID"))}