对不起那个菜鸟问题..但这就是我做的事情
Dim cmd As New SqlCommand("Declare @mychar varchar(60) " & _
"Set @mychar = '" & TextBox2.Text & "'" & _
"Select * from @mychar", conn)
Dim rdr As SqlDataReader = cmd.ExecuteReader
While rdr.Read()
ListView2.Items.Add(rdr("Account"))
End While
rdr.Close()
但是我收到一条错误,上面写着“必须声明表变量”@mychar“。”怎么了 ?或者这不仅仅是可能的吗?提前谢谢..
答案 0 :(得分:1)
Dim cmd As New SqlCommand(" Select * from " & TextBox2.Text & " ", conn)
Dim rdr As SqlDataReader = cmd.ExecuteReader
While rdr.Read()
ListView2.Items.Add(rdr("Account"))
End While
rdr.Close()