注册 登录
编程论坛 VB.NET论坛

vb2005如何获得access表中N列N行的数据?

satanskiss 发布于 2008-07-29 15:33, 2511 次点击
一个access表:test 有三个键:Id(整数类型)  tname(字符串类型) add(字符串类型)
表中有20条完整的记录,请问如何连接数据库,(select * from test)并在连接后获取第10行的Tname列的数据?
4 回复
#2
satanskiss2008-07-29 15:39
我是这么连接的 如下:
Dim strconn As String = "Provider=Microsoft.jet.oledb.4.0;data source=" & My.Application.Info.DirectoryPath & "\test.mdb;persist security info=false"
Dim objconn As New Data.OleDb.OleDbConnection(strconn)
Dim s As String = "select * from test order by id desc"
Dim objReader As Data.OleDb.OleDbDataAdapter
objconn.Open() '打开数据库连接
Dim dr As OleDb.OleDbDataReader
Dim cmdQx As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand(s, objconn)
dr = cmdQx.ExecuteReader

后面不知道怎么进行操作了 ?
#3
satanskiss2008-07-29 15:40
刚学不久,请高手指点迷津
#4
satanskiss2008-07-29 18:45
#5
qlong07282008-08-01 14:50
Dim strconn As OleDb.OleDbConnection
strconn = "Provider=Microsoft.jet.oledb.4.0;data source=" & My.Application.Info.DirectoryPath & "\test.mdb;persist security info=false"
objconn.Open() '打开数据库连接
Dim s As String = "select * from test order by id desc"
Dim RS As New DataSet
Dim DA As New OleDb.OleDbDataAdapter
DA.SelectCommand = New OleDb.OleDbCommand(s, objconn)
DA.Fill(RS)
第10行的Tname=RS.Tables(0).Rows(9)("Tname")
1