int n =Count("SELECT COUNT(*) FROM information_schema.SCHEMATA");; //return 6
TreeNode[] db_name = new TreeNode[n];
MySqlCommand cmd = new MySqlCommand("show databases", connection);
MySqlDataReader dataReader = cmd.ExecuteReader();
for(i=0;i<n;i++)
{
dataReader.Read();
db_name[i] = new TreeNode(dataReader[i].ToString());
}
Why do I get IndexOutOfRangeException was unhandled,Index was outside the bounds of the array? If the Count() funciont return 6 that means there are 6 rows so 6 fields [0][1][2][3][4][5] I put a breakpoint in the for loop and I get the error at the second loop, when i=1. How can I fix that? I can't see the error. Thanks in advance.