I am looking to move data in a arraylist for a Listbox, but it is giving error. Error :
An unhandled exception of type 'System.InvalidCastException' occurred in System.Data.dll Additional information: You can not convert an object of type 'System.Int32' on type 'System.String'.
This happens on line: fill_arry[i] = objReader.GetString(1);
Code:
public void Fill_List(ArrayList fill_arry)
{
SqlDataReader objReader;
SqlCommand objcmd =null;
int i = 0;
vsql = "SELECT [NOME] As Identificador,[RGP],[NOME],[ENDERECO],[CIDADE],[ESTADO],[TELEFONE],[CELULAR] FROM pescador";
if (this.Conectar())
{
try
{
objcmd = new SqlCommand(vsql, objCon);
objReader = objcmd.ExecuteReader();
while (objReader.Read())
{
fill_arry[i] = objReader.GetString(1);
}
}
catch (SqlException erro)
{
throw erro;
}
finally
{
this.Desconectar();
}
}
}