mituozo
November 11th, 2008, 03:28 PM
Hello everyone,
I'm trying to make an array from the return of a MySQL query but keep getting the following error message:
Error 1 Use of unassigned local variable 'QueryArray'
The line it refers to is the "return QueryArray;"
I keep trying different methods to try and get this to work but I'm getting no where.. So any help would be much appreciated. It's a generic query handler I'm making, so I don't know how big the array is going to be before the query is executed..
public static string[][] ReturnQueryArray(MySql.Data.MySqlClient.MySqlConnection Source, string SQLQuery)
{
MySql.Data.MySqlClient.MySqlCommand MyQuery = Source.CreateCommand();
MySql.Data.MySqlClient.MySqlDataReader Reader;
MyQuery.CommandText = SQLQuery;
Reader = MyQuery.ExecuteReader();
int counter = 0;
string[][] QueryArray;
while (Reader.Read())
{
for (int i = 0; i < Reader.FieldCount; i++)
{
QueryArray[counter][i] = Reader.GetValue(i).ToString();
}
counter = counter + 1;
}
return QueryArray;
}
I'm trying to make an array from the return of a MySQL query but keep getting the following error message:
Error 1 Use of unassigned local variable 'QueryArray'
The line it refers to is the "return QueryArray;"
I keep trying different methods to try and get this to work but I'm getting no where.. So any help would be much appreciated. It's a generic query handler I'm making, so I don't know how big the array is going to be before the query is executed..
public static string[][] ReturnQueryArray(MySql.Data.MySqlClient.MySqlConnection Source, string SQLQuery)
{
MySql.Data.MySqlClient.MySqlCommand MyQuery = Source.CreateCommand();
MySql.Data.MySqlClient.MySqlDataReader Reader;
MyQuery.CommandText = SQLQuery;
Reader = MyQuery.ExecuteReader();
int counter = 0;
string[][] QueryArray;
while (Reader.Read())
{
for (int i = 0; i < Reader.FieldCount; i++)
{
QueryArray[counter][i] = Reader.GetValue(i).ToString();
}
counter = counter + 1;
}
return QueryArray;
}