Hi,
I receive the error message in the below code:
System.IndexOutOfRangeException: TenantName
vb:line 709
Code:
Try
Using con As New SqlConnection("Data Source=DESKTOP-O6TSDMJ;Initial Catalog=RCMS;Integrated Security=True")
DsUnitdetails.EnforceConstraints = False
Me.VwunitdetailsTableAdapter.Fill(Me.DsUnitdetails.vwunitdetails, TxtPropertyIDClick.Text)
con.Open()
Using cmd As New SqlCommand("Select tenantfullname from tbltenants order by firstname", con)
Using myreader As SqlClient.SqlDataReader = cmd.ExecuteReader
TenantName.Items.Clear()
While myreader.Read
TenantName.Items.Add(myreader("TenantName"))
End While
End Using
End Using
con.Close()
I have similar code as the above for another combobox and at runtime it doesn't give me the error, I am confused...
The code is as follows:
Code:
Try
Using con As New SqlConnection("Data Source=DESKTOP-O6TSDMJ;Initial Catalog=RCMS;Integrated Security=True")
DsUnitdetails.EnforceConstraints = False
Me.VwunitdetailsTableAdapter.Fill(Me.DsUnitdetails.vwunitdetails, TxtPropertyIDClick.Text)
con.Open()
Using cmd As New SqlCommand("Select flattype from lkupflattype", con)
Using myreader As SqlClient.SqlDataReader = cmd.ExecuteReader
FlatType.Items.Clear()
While myreader.Read
FlatType.Items.Add(myreader("FlatType"))
End While
End Using
End Using
con.Close()
End Using
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
What am I doing wrong?
Thank you!