控件代码如下
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
sqlcon = new SqlConnection(strcon);
sqlcon.Open();
SqlCommand sqlcmd = new SqlCommand();
sqlcmd.Connection = sqlcon;
string name = "";
name = comboBox1.Text.ToString();
Console.WriteLine(comboBox1.Text.ToString());
sqlcmd.CommandText = "select Money from nini where Name = " + name.ToString(). Trim();
sqlcmd.CommandType = CommandType.Text;
SqlDataReader reader = sqlcmd.ExecuteReader();
while (reader.Read())
{
listView1.Items.Add(reader[0].ToString());
textBox1.Text = reader[0].ToString();
}
}
![图片说明](https://img-ask.csdn.net/upload/201703/04/1488601975_121709.png)
但是报错了,如何才能解决
![图片说明](https://img-ask.csdn.net/upload/201703/04/1488602066_109729.png)
数据库数据如下
![图片说明](https://img-ask.csdn.net/upload/201703/04/1488602135_605182.png)