在MsgBox中显示数据库结果的最后一行.. 我想使用rows.add函数将sql结果添加到datagrid ..
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