以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- 请老师检查作业,动态列表项目,我又错哪了? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=1617)
|
-- 作者:菜鸟foxtable
-- 发布时间:2009/1/13 9:02:00
-- 请老师检查作业,动态列表项目,我又错哪了?
ComboBox1的MouseEnter里有如下代码:
Dim cmd As New SQLCommand cmd.Con nection Name = "zygl"这里故意留空格的. Dim lst As WinForm.ComboBox Dim dt As DataTable cmd.CommandText = "Select 床位 From [住院登记] where 出院结账 = False" dt = cmd.ExecuteReader() lst = e.Form.Controls("ComboBox1") lst.Items.clear If dt.datarows.count >0 Then For Each dr As Datarow In dt.Datarows lst.Items.Add(dr("床位")) Next End If
当住院登记表里所有行床位列都为空时报错......WHY?
此主题相关图片如下:001.jpg
[此贴子已经被作者于2009-1-13 9:06:37编辑过]
|
-- 作者:czy
-- 发布时间:2009/1/13 12:16:00
--
加个判断吧。
Dim cmd As New SQLCommand cmd.C Dim lst As WinForm.ComboBox Dim dt As DataTable cmd.CommandText = "Select 床位 From [住院登记] where 出院结账 = False" dt = cmd.ExecuteReader() lst = e.Form.Controls("ComboBox1") lst.Items.clear If dt.datarows.count >0 Then For Each dr As Datarow In dt.Datarows if dr("床位") IsNot Nothing Then lst.Items.Add(dr("床位")) End If Next End If
|