[VB.NET]怎样提取查询结果中每个子段的内容

前端之家收集整理的这篇文章主要介绍了[VB.NET]怎样提取查询结果中每个子段的内容前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
怎样提取查询结果中每个子段的内容 具体的代码是这样的: 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() 等方法 参数是字段索引值 __________________________________________________________________________ dr(T_USER表的各字段).ToString() & __________________________________________________________________________ 是不是可以将dr(username).ToString()直接赋给一个变量参数呢? __________________________________________________________________________ 该回复于2008-08-05 03:40:50被管理员或版主删除 __________________________________________________________________________ 怎么用呀? dr(T_USER表的各字段).ToString() 语法报错说:dr不是表达式 __________________________________________________________________________ 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() & __________________________________________________________________________ 问题解决了 用的方法是 str = ds.Tables(0).Rows(i)(i).ToString().Trim() 多谢大家的帮忙! __________________________________________________________________________

猜你在找的VB相关文章