专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VB Dotnet

求高手帮忙看下 程序的有关问题 ~

发布时间:2011-06-23 16:03:15 文章来源:www.iduyao.cn 采编人员:星星草
求高手帮忙看下 程序的问题 ~~~~~
我想根据listbox中的项选出表中对应的记录 我先将listbox中的项存入数组,再遍历数组,连接表,从表中选出对应记录放到dataset中 可以这样吗???一运行就有错啊~~~
  Dim i As Integer
  Dim t As Integer
  Dim s() As String
  t = ListBox1.Items.Count
  ReDim s(t - 1)
  For i = 0 To t - 1
  s(i) = ListBox1.Items(i)
  Next

  Dim str As String
  For Each str In s

  conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=lvyou1.mdb"
  comm.CommandText = "select * from 景点 where name=" + str
  comm.Connection = conn
  dap.SelectCommand = comm
  conn.Open()
  dap.Fill(da)
  conn.Close()
  Next
  Dim dt3 As New DataTable
  dt3 = da.Tables(0)

------解决方案--------------------
VB.NET code
Dim i As Integer
  Dim t As Integer
 t = ListBox1.Items.Count

  Dim s(t-1) As String
  For i = 0 To t - 1
  s(i) = ListBox1.Items(i)
  Next

  Dim str As String
 conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=lvyou1.mdb"
 comm.Connection = conn

  For Each str In s
    comm.CommandText = "select * from 景点 where name= '" + str + "'"
    dap.SelectCommand = comm
    dap.Fill(da)
  Next
  Dim dt3 As DataTable = da.Tables(0)
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: