1.11M Members

DropDownBox in VB.NET 2010

 
0
 

Hi there,
I have problem with my DropDownBox, my datasource is from MySQL database. My problem is this, I have already stored data in my database let's say 12 rows, but when I am trying to fetch it on to dropdownbox, only 11 data will be the item values of the dropdownbox.

        myconnstring = "datasource=localhost;username=root;password=*******;database=**********;"
        comm = "SELECT * FROM players WHERE `team`='" & TeamBox.Text & "';"
        conn = New MySqlConnection(myconnstring)
        Try
            conn.Open()
            Try
                myCommand.CommandText = comm
                myCommand.Connection = conn
                myReader = myCommand.ExecuteReader
                While myReader.Read
                    If SPTexbox.Items.Count <= 12 Or SPnumTexbox.Items.Count <= 12 Then
                        SPTexbox.Items.Add(myReader("playernam"))
                        SPnumTexbox.Items.Add(myReader("plnum"))
                    End If
                End While
                conn.Dispose()
            Catch myerror As MySqlException
                'error message
            End Try
        Catch myerror As MySqlException
            'error message
        End Try

Datas from table row's 1-10 and 12, row 11 is not included.

 
0
 

if your try to run the query in mysql, what is the result?
and please put a proper error message to your catch block.
ex:

Catch myerror as MySqlException
    Msgbox("An error has occured. " & myerror.Message)
End Try

this will display a specific error message for easier debugging

 
0
 

Hi,

Row 11 could be different in some way did you manually populate the table? Is there a chance there is a leading or trailing space for example ("United" vs "United ")? Are the team names in the same case ("United" vs "united")

If you remove the clause about the count of the items and just populate the text box does it appear?

 
0
 

G Waddell
All rows are have the same case and spacing because, TeamBox.text is also a combobox, I just using .text in getting the selected item. The teams are already in there, only to choose what team.
I haven't tried yet in displaying another control.

 
0
 

Hi
Try this mod and see what happens:

 While myReader.Read
     SPTexbox.Items.Add(myReader("playernam"))
     SPnumTexbox.Items.Add(myReader("plnum"))
 End While
 conn.Dispose()

i.e. remove the limit on the item count and see if the row appears...

 
0
 

I changed already unto that, I didn't see the result yet because I used another pc.
By the way, why is it that if the project that is coded from 1pc cannot be change the output in another pc?

 
0
 

Hi,

Not sure what you ment by that last comment?

Do you mean you are coding the same code on two different machines?

Do you have a source code versioning application such as SourceSafe or SVN? You would need something like this to check in and out the source code from a central repository to the different machines that you code on. Your code is being held locally on the machine you develop on if you make a change on machine A and don't synch/port that change to machine B then your code is out of step.

If you mean you made the change and have two machines running the program but the change only appeared on machine A it may mean you have to redeploy (Or reinstall,) your program to machine B

 
0
 

Ok thanks!

Question Answered as of 1 Year Ago by G_Waddell and daniel955
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article