0

Here is my code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitializeComponent()
Dim str As New StreamReader("C:\projects\servers.txt")
Dim server As String = str.ReadToEnd().ToString()
str.Close()
Dim thisconnection As New SqlConnection("server=" & server & ";integrated security=True;database=Deduping")
Dim thisAdapter As New SqlDataAdapter()
Dim cmdthisAdapter As New SqlCommand("SELECT ProjectNumber, ProjectName FROM Projects", thisconnection)
thisAdapter.SelectCommand = cmdthisAdapter
Dim thisdataset As New DataSet()
thisAdapter.Fill(thisdataset, "ProjectNumbers")
For Each therow As DataRow In thisdataset.Tables("ProjectNumbers").Rows
Dim proj As String = therow("ProjectNumber").ToString()
ComboBoxProject.Items.Add(therow("ProjectNumber"))
Next
thisconnection.Close()
End Sub

I've added the proj string in just to ensure that a valid string is present in therow("projectnumber").tostring() and it is. For some reason the combobox is not updating with the data.

Please help!

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by babbu
0

BTW, I've also tried comboboxproject.items.add(therow("projectnumber")).tostring() to no avail.

0

u cannot add the complete row to the combo box.
u will add the value of a column
so
combobox.items.add(datarow("Column name").tostring)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.