前端之家收集整理的这篇文章主要介绍了
[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 str
sql As String = SELECT * FROM T_USER WHERE userid= & id Dim comm As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand(str
sql,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 Str
sql As String = SELECT * FROM T_USER WHERE userid= & id Dim da As New OleDbDataAdapter(Str
sql,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 Msg
Box(ex.ToString()) Finally con.Close() End Try __________________________________________________________________________ 比如说:username是表中的一个字段, 那么写法就是:dim strUsername as string = dr(“username”).ToString() & __________________________________________________________________________ 问题
解决了 用的
方法是 str = ds.Tables(0).Rows(i)(i).ToString().Trim() 多谢大家的帮忙! __________________________________________________________________________
原文链接:https://www.f2er.com/vb/263708.html