I am creating a program that will generate X number of codes that must not already exist in a MySQL table.I am trying to read all of the codes in the current table, and store it within an array. However, I can't seem to get that to work, either. Below is the code that I have, but I get an error within the while block indicating that ExistingCodes has not been initialized, which puzzles me. Use of unassigned local variable 'ExistingCodes' is the precise error. What am I doing wrong here? Is there a better way of doing this? Keep in mind that I am going to use this array to check against when generating the new codes, and adding the new codes as they are generated.
public static string GetExistingCodes
int index = 0;
string sql = "SELECT code from `gift_codes`";
MySqlCommand cmd = new MySqlCommand(sql, Conn);
MySqlDataReader rdr = cmd.ExecuteReader();
ExistingCodes[index] = rdr.GetString(0);