在 MsgBox 中显示数据库结果的最后一行。我想使用 rows.add 函数将 sql 结果添加到数据网格中。
Try
GetDataConn(".", "restaurant", True)
Dim sqlcmd As New SqlCommand("SELECT i.item_id as 'item', i.item_name as 'name', i.price as 'price', t.item_qty as 'qty' FROM item_tbl i, temp_tbl t WHERE t.item_id = i.item_id AND t.table_id ='" & id.Trim & "' ", sqlConn)
Dim myreader As SqlDataReader
myreader = sqlcmd.ExecuteReader()
myreader.Read()
While myreader.hasRow()
'frmMain.posdatagrid.Rows.Add(myreader.Item("item"), myreader.Item("name"), myreader.Item("price"), myreader.Item("qty"), myreader.Item("price") * myreader.Item("qty"))
MsgBox(myreader.Item("item"))
myreader.NextResult()
End While
Catch ex As Exception
sqlcmd.Dispose()
End Try