日期:2014-05-17  浏览次数:20805 次

求助!!checkedlistbox问题
for (int d = 0; d < checkedListBox1.Items.Count; d++)
            {
                if (checkedListBox1.GetItemChecked(d))
                {
                    string st = this.checkedListBox1.Items.ToString();
                    string str3 = "insert into bingli(哮喘症状) values('" + st + "') ";
                    SqlCommand com3 = new SqlCommand(str3, con);
                    com3.ExecuteNonQuery();
                }
            }

要将选中的checkedlistbox的内容存入数据库,但是以上代码运行有误,求查看。。。。
数据库连接已经写在前面了。。

------解决方案--------------------
病人编号这一列不能为空?那就赋个默认值啊
------解决方案--------------------
 string st1 = this.checkedListBox2.CheckedItems[c].ToString();
=>
 string st1 = this.checkedListBox2.Items[c].ToString();