帮我看下这段代码哪里错了好吗??谢谢!!
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编辑过]