View seareched rows in MySQL databas
Date: November 15, 2008 01:14PM
I'm trying to view some results from my MySQL database in a C# Windows application.
I included the: "MySQL.Data.MySQLClient" in my application and I have send the "SELECT"-statement to the MySQL-server. The statement works, I have checked it in Query Browser. The result shows two rows, which I want.
Now I want to store each row and each colums with it, in a C# dictionary.
The problem is, the code I'm using only store in row in the dictionary, the last row which was found with the "SELECT"-statement is not stored in the dictionary. How do I solve this?
I use this code in my C# application to store the data into my dictionary:
Dictionary<int, Collection<string>> rowData = new Dictionary<int, Collection<string>>();
int rowIndex = 0;
// The code to with the "SELECT"-statement is send to the MySQL-server.
while (mySQLReader.Read()) // mySQLReader is a variable of MySQLDataReader.
{
rowData[rowIndex] = new Collection<string>();
for (int i = 0; i < 5; i++)
{
rowData[rowIndex].Add(mySQLReader.GetString(i));
}
mySQLReader.NextResult(); // Don't know it this do anyting.
rowIndex++;
}
Please help.
Sorry, you can't reply to this topic. It has been closed.
© 1995-2008 MySQL AB, 2008- Sun Microsystems, Inc.