各位大神,VB.net怎样输出access数据库中某一个表中的最后一行
各位大神我想将access数据库中输出某一个表中最后一行中某一列数据到TextBox13,下面的程序已经实现了第一行中某一列数据输出到TextBox13,要是想要最后一行的该怎么办?麻烦各位前辈指教一下!
Imports System.Data.OleDb
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim cstring As String = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & nowpath & ";Persist Security Info=False;Jet OLEDB:Database Password=123"
Dim con As New OleDb.OleDbConnection(cstring)
'Dim mydatareader As OleDbDataReader
Dim sql As String = "select 混合流量S from 钻孔运行参数"
con.Open()
Dim cmd As New OleDb.OleDbCommand(sql, con)
Dim myreader As OleDbDataReader = cmd.ExecuteReader
Dim dt As New DataTable
myreader.Read()
TextBox13.Text = myreader(0)
con.Close()
VB.net
[解决办法]
System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter("select 混合流量S from 钻孔运行参数", con)
Dim ds As New DataSet
da.Fill(ds)
TextBox13.Text = ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1)("混合流量S").ToString()