Nie można rzutować obiektu typu „System.Int32”, aby wpisać „System.String” w DataReader.GetString ()
Próbowałem dodać dane z bazy danych do acomboboxa.
try
{
SqlCeCommand com = new SqlCeCommand("select * from Category_Master", con);
SqlCeDataReader dr = com.ExecuteReader();
while(dr.Read()){
string name = dr.GetString(1);
cmbProductCategory.Items.Add(name);
}
}
catch(Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message, System.Windows.Forms.Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Mam następujący wyjątek:
Nie można rzutować obiektu typu „System.Int32” na typ „System.String”
Czego mi tu brakuje?