I have this piece of code that is not populating combobox from datareader. I have done all kinds of checks and confiirmed that the database is connecting and the query is also correct. Databaseconnections is a module where I have declared all my variables including connection string and datareader(Public dr As SqlDataReader). When debbuging everything goes smoothly but when I hit the While loop it jumps to the end of the loop without any errors. I cant understand what am missing out. Please help.
Public Sub loadLocatns()
Try
Openconn()
cmd.CommandText = "SELECT distinct jobs.[file] FROM [BERVSDB].[dbo].[jobQueue] as jobs where (jobs.form_status<>'c') and (jobs.CI = '" & Ccode & "') and (jobs.[file] in( SELECT dts.[file] from [BERVSDB].[dbo].[master] as dts where (dts.[status] is null) or (dts.[status] <> 'X') ))"
cmd.Connection = conn
Databaseconnections.dr = cmd.ExecuteReader()
If IsNothing(dr) Then
MessageBox.Show("No Data found")
Else
If dr.Read() Then
While dr.Read
Me.ComboBox1.Items.Add(dr(0))
End While
Else
MessageBox.Show("Not reading!")
End If
dr.Close()
conn.Close()
End If
Catch ex As Exception
MessageBox.Show("Error:" & ex.Message)
End Try
End Sub