データベースからコンボボックスにデータを追加しようとしていました。
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' にキャストできません
ここで何が欠けていますか?