Sometimes when using a SqlDataReader it's important to check for null values before accessing the item. Here's how:
int id = 0;
SqlDataReader r = cmd.ExecuteReader();
while (r.Read())
{
	if (!r.IsDBNull(0))
		id = r.GetString(0);
}