[求助]关于用程序访问数据库的问题(内见代码)
在visual studio中,同一个窗体中的两个listbox,需要各自添加来自不同数据表的数据,但是一个按钮实现后,在运行另一个按钮,提示错误“在位置0处没有行”请高手指教!!!
一个按钮
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
m_ = "select * from purchase where class='" & Cmbclass.Text & "'"
m_cmd.Connection = m_con
m_ada.SelectCommand = m_cmd
m_ada.Fill(m_ds, "purchase")
For i As Integer = 0 To m_ds.Tables(0).Rows.Count - 1
ListBox1.Items.Add(m_ds.Tables(0).Rows(i)(3) & " " & m_ds.Tables(0).Rows(i)(9) & "本")
next
sub
第二个按钮
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
m_ = "select * from inventory where bookname='" & TextBox1.Text & "'"
m_cmd.Connection = m_con
m_ada.SelectCommand = m_cmd
m_ada.Fill(m_ds, "inventory")
ListBox2.Items.Add(m_ds.Tables(0).Rows(0)(0) & " " & m_ds.Tables(0).Rows(0)(6))
End Sub
[[it] 本帖最后由 被放逐 于 2008-6-18 22:34 编辑 [/it]]