I'm new at mysql.. wanted some help if you wouldn't mind.
this is what I have:
Code:Dim conn As MySql.Data.MySqlClient.MySqlConnection Dim sqlquery As String Dim myAdapter As New MySql.Data.MySqlClient.MySqlDataAdapter() Dim myData As MySql.Data.MySqlClient.MySqlDataReader Dim myCommand As New MySql.Data.MySqlClient.MySqlCommand() Dim i As Integer = 0Code:conn = New MySql.Data.MySqlClient.MySqlConnection() conn.ConnectionString = "server=0.0.0.0; user id=username; password=password; database=database1" 'see if connection failed. Try conn.Open() Catch myerror As System.Data.SqlClient.SqlException MessageBox.Show("Error Connecting to login server. program cannot run without a connection! " & myerror.Message) Me.Close() End Try sqlquery = "SELECT username FROM pool WHERE css='1' LIMIT 0 , 30" myCommand.Connection = conn myCommand.CommandText = sqlquery myAdapter.SelectCommand = myCommand myData = myCommand.ExecuteReader() myData.Read() If myData.HasRows = True Then Dim ddddd As Object i = 0 For Each ddddd In myData.Item(i) ListBox1.Items.Add(myData.Item(i)) i = i + 1 Next Else MessageBox.Show("no accounts found") End If
With that code, the first account (item index 0) loads into the listbox, but it when it goes round the loop again, to try to input the next row (index 1), it says this error:
Index was outside the bounds of the array.
so I can easily do it if there is only 1 row, but if I want to display multiple results in the listbox it always comes up with this error.
could anyone help?
I'm using .net mysql connector by the way
Thanks you




Reply With Quote