The error is: Use of unassigned local variable 'vehicleID'.
string vehicleID;
try
{
conn.Open();
reader = com.ExecuteReader(Commandbehavior.CloseConnection);
while (reader.Read())
{
//this is where I am attempting to assign the vehicleID variable to the
//result of the getstring method
vehicleID = reader.GetString(0);
}
}
catch (Exception exc)
{
lblException.Visible = true;
lblException.Text = "There is a problem with your connection: " + exc.ToString();
}
finally
{
conn.Close();
}
// get result from SELECT above and convert to int
int vehicle = Convert.ToInt16(vehicleID);
//this is where it hits an error - it says that vehicleID is not assigned to
I think I'm missing something small and frustrating...
How can I get hold of that variable?
Thanks.

New Topic/Question
Reply




MultiQuote






|