【发布时间】:2018-04-05 04:41:23
【问题描述】:
代码
SqlCommand cmd = new SqlCommand("select billno from tpdetail", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
AutoCompleteStringCollection MyCollection = new AutoCompleteStringCollection();
while (reader.Read())
{
MyCollection.Add(reader.GetString(0).ToString());
}
textBox3.AutoCompleteCustomSource = MyCollection;
我得到以下异常:
无法将“System.Int32”类型的对象转换为“System.String”类型
【问题讨论】:
-
这里没有足够的信息......可能 MyCollection 需要一个 int 而不是字符串
-
复制这里已经有答案:stackoverflow.com/questions/19582256/…
标签: c# sql-server