-1
我想顯示我想要選擇的內容,但我只得到1行。如何解決它PLZ? 我只獲取第一行數據,但是當我在第二輪中執行操作時,它跳過循環並結束該過程。無法在VB.net中查詢多行MySQL數據庫
ListView1.Items.Clear() SQLstring = "SELECT * From record WHERE member_code like '" & u1 & "' " SQLConnection.Open() SQLcommand = New MySqlCommand(SQLstring, SQLConnection) SQLdatareader = SQLcommand.ExecuteReader() Do While SQLdatareader.Read() a = (SQLdatareader.Item("book_code").ToString()) b = (SQLdatareader.Item("member_code").ToString()) c = (SQLdatareader.Item("book_status").ToString()) d = (SQLdatareader.Item("Borrow_date").ToString()) f = (SQLdatareader.Item("Due_date").ToString()) SQLdatareader.Close() SQLcommand.Dispose() SQLConnection.Close() SQLstring = "SELECT * From book WHERE book_code like '" & a & "' " SQLConnection.Open() SQLcommand = New MySqlCommand(SQLstring, SQLConnection) SQLdatareader = SQLcommand.ExecuteReader() Do While SQLdatareader.Read() g = (SQLdatareader.Item("book_name").ToString()) h = (SQLdatareader.Item("book_writer").ToString()) i = (SQLdatareader.Item("book_year").ToString()) Loop Dim SQLlist As ListViewItem = ListView1.Items.Add(g) SQLlist.SubItems.Add(h) SQLlist.SubItems.Add(i) SQLlist.SubItems.Add(d) SQLlist.SubItems.Add(f) If dtNow > f Then Dim fine_amount = f.Subtract(dtNow) SQLlist.SubItems.Add(fine_amount) Else SQLlist.SubItems.Add("0") End If Loop SQLdatareader.Close() SQLcommand.Dispose() SQLConnection.Close() End Sub