标题:关于ListBox1_SelectedIndexChanged的用法?
取消只看楼主
YAXIONG
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2006-11-6
 问题点数:0 回复次数:0 
关于ListBox1_SelectedIndexChanged的用法?

帮我看下这段代码哪里错了好吗??谢谢!!
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

Dim curItem As String = ListBox1.SelectedItem.ToString()
Dim rd As SqlDataReader
sd.CommandText = sd.CommandText + "where V_num= @num"
Try
SqlConnection1.Open()
Dim cn As New SqlCommand(sd.CommandText, SqlConnection1)
Dim n As New SqlParameter("@num", SqlDbType.Char, 18)
cn.Parameters.Add(n) '加入参数
n.Value = curItem '赋值
cn.ExecuteNonQuery() '执行已经定义好的命令

rd = cn.ExecuteReader()
While rd.Read
num.Text = rd(0)
End While
rd.Close()
Catch ex As Exception
Finally
' rd.Close()
End Try
End Sub
其中,CommandText原有"select V_num from vister",我在from_load中,先让ListBox输出num的信息,我希望在ListBox中选择项时,num.text输出相应的信息,可是num.text都没有输出任何信息!!
请大家帮帮忙啊!!谢谢了!!

[此贴子已经被作者于2007-3-31 11:22:37编辑过]

搜索更多相关主题的帖子: 用法 
2007-03-31 11:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-128297-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.060046 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved