帮助我使用asp.net和vb.net使用DataReader将数据库中的数据检索到文本框中 [英] Help me to retrieve data from a database into textboxes using a datareader, using asp.net and vb.net
本文介绍了帮助我使用asp.net和vb.net使用DataReader将数据库中的数据检索到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请问我在aspx表单上有以下文本框,它们对应于名为表的字段;
txtClientID,txtFirstName,txtLastName,txtDOB,txtDateRegistered,txtExpiryDate
我想检索存储在名为ClientDatails的sql server 2005数据库表中相应字段中的数据.
我想使用DataReader来实现这一目标,您能帮我吗
Please i have the following text boxes on my aspx form corresponding to fields on a table named;
txtClientID, txtFirstName,txtLastName, txtDOB, txtDateRegistered,txtExpiryDate
I want to retrieve data stored in the corresponding fields in an sql server 2005 database table named;ClientDatails
I want to use DataReader to achieve this can you please help me
推荐答案
Dim cnPodaci AsNew SqlConnection
cnPodaci.ConnectionString = "your connection string"
cnPodaci.Open()
Dim cm AsNew SqlCommand
cm.CommandText = "SELECT * FROM TABLE"
cm.Connection = cnPodaci
Dim dr As SqlDataReader
dr = cm.ExecuteReader
If dr.HasRows Then
dr.Read()
txtBox1.text = dr.Item("ColumnName1")
txtBox2.text = dr.Item("ColumnName2")
dr.Close()
EndIf
cnPodaci.Close()
阅读此 [ ^ ]!
http://bytes.com/topic/net/insights/635615-how- use-database-your-program [ ^ ]
http://bytes.com/topic/net/insights/817960-how-use-database-your-program-part-ii [
http://bytes.com/topic/net/insights/635615-how-use-database-your-program[^]
http://bytes.com/topic/net/insights/817960-how-use-database-your-program-part-ii[^]
这篇关于帮助我使用asp.net和vb.net使用DataReader将数据库中的数据检索到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文