Невозможно привести объект типа «System.Int32» к типу «System.String» в DataReader.GetString ().
Я пытался добавить данные из базы данных в acombobox.
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);
}
Я получаю следующее исключение:
Невозможно привести объект типа 'System.Int32' печатать 'System.String»
Что мне здесь не хватает?