blah blah blah is here! blah blah » Close

up1down
link

Hello I have an mysql table that have 8 columns!

I wand to read one of the column (tameio) and display the raws in a list box


string MyConString = "SERVER=192.168.0.1;" + "DATABASE=mydata;" + "UID=user;" + "PASSWORD=123456;";

string netselect = "mytable";

MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "select table.tameio from table";


connection.Open();

Reader = command.ExecuteReader();
label6.ForeColor = System.Drawing.Color.Lime;
label6.Text = "SERVER ONLINE ";
while (Reader.Read())
{
string thisrow = "";
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString();

listBox1.Items.Add(thisrow);

}
connection.Close();






but in listbox i get only the first raw
any help?????

last answered one year ago

3 answers

up1down
link

did you make a debug for that? if you did and it only looped once then the result is right and you code here is right so check the connection ip and database if its taking data from a different database or server and check the table itself if it only has one row.

up0down
link

its ok the code work the problem is in some raws i have null content!

is any way to ignore the null -empty content and to move to next raw?

up0down
link

Try changing the query to:

command.CommandText = "SELECT table.tameio FROM table WHERE (table.tameio IS NOT NULL && table.tameio !='')";

Incidentally, 'table' is a reserved word in MySql so I assume your actual table name is something else.

Feedback