急求,如何从已经和VB链接好的access数据库里读取一列数据中最大的数据,并把这个数据放在text里显示
展开全部
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db.mdb"
Dim con As New OleDb.OleDbConnection(cstring)
Dim sql As String = "select max(字段名) from 表名"
con.Open()
Dim cmd As New OleDb.OleDbCommand(sql, con)
Dim myreader As OleDbDataReader = cmd.ExecuteReader
myreader.Read
TextBox1.Text = myreader(0)
con.Close()
End Sub
Dim cstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db.mdb"
Dim con As New OleDb.OleDbConnection(cstring)
Dim sql As String = "select max(字段名) from 表名"
con.Open()
Dim cmd As New OleDb.OleDbCommand(sql, con)
Dim myreader As OleDbDataReader = cmd.ExecuteReader
myreader.Read
TextBox1.Text = myreader(0)
con.Close()
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询