怎样提取查询结果中每个子段的内容
具体的代码是这样的:
Dim id As String = Request( "userid ")
Dim str As String = "Provider=MSDAORA.1;data source=kksb;user id=kksb;password=kksb2007; "
Dim conn As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(str)
Dim dr As System.Data.OleDb.OleDbDataReader
conn.Open()
Dim strSQL As String = "SELECT * FROM T_USER WHERE userid= " & id
Dim comm As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand(strSQL,conn)
dr = comm.ExecuteReader()
之后怎样才能提取到各个字段的内容?
[解决办法]
dr.GetString() 等方法
参数是字段索引值
[解决办法]
Dim id As String = Request( "userid ")
Dim str As String
Dim connStr As String = 数据连接语句
Dim con As New OleDbConnection(connStr)
Dim StrSql As String = "SELECT * FROM T_USER WHERE userid= " & id
Dim da As New OleDbDataAdapter(StrSql, con)
Dim ds As New DataSet
Try
con.Open()
da.Fill(ds)
'str=查询结果的第i行第i列
str = ds.Tables(0).Rows(i)(i).ToString().Trim()
Catch ex As Exception
MsgBox(ex.ToString())
Finally
con.Close()
End Try
[解决办法]
比如说:username是表中的一个字段,
那么写法就是:dim strUsername as string = dr(“username”).ToString() & " "