Wrox Programmer Forums
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2005, 05:13 AM
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to NitinJoshi
Default Datareader

how can i bind data to my different textboxes using datareader....?
Also how i move forward & backward
Thanx for u r reply
 
Old January 11th, 2005, 09:13 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Nitin,
       Using DataReader u can't move forward and Backward.
U can set the data to different textboxes using DataReader like this
(Eg)
SqlConnection sqlConn=new SqlConnection(strConn);
strSql="select job_id,job_desc,min_lvl,max_lvl from jobs where job_id>="+st+" and job_id<="+nt+"";
sqlConn.Open();
SqlCommand strComm=new SqlCommand("select * from TestNText",sqlConn);
SqlDataReader sqlRead=strComm.ExecuteReader();
while (sqlRead.Read())
{
   TextBox1.Text = sqlRead.GetValue(0);
}
sqlRead.Close();
sqlConn.Close();

 
Old January 13th, 2005, 06:31 AM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Because the DataReader supports the IEnumerable interface, it can be bound directly to the DataSource property of a Web control or any other control that supports data binding.



It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
 
Old January 26th, 2005, 01:50 AM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jackat_78
Default

 Dim objsqladapter As SqlClient.SqlDataAdapter
        Dim strSQL As String = "select * from vw_geninfo_upd"
        'Set the dataset object
        Dim myDataset As New DataSet
        'Set the connedction string to new instance
        DBConn = New DBConnect
        sqlconnection = New SqlClient.SqlConnectio(DBConn.ConnString)
        sqlconnection.Open()
        Dim sqlcommand As SqlClient.SqlCommand
        sqlcommand = New SqlClient.SqlCommand
        sqlcommand.Connection = sqlconnection
        sqlcommand.CommandText = strSQL
        objsqladapter = New SqlClient.SqlDataAdapter(sqlcommand.CommandText, sqlconnection)
        objsqladapter.Fill(myDataset, "vw_geninfo_upd")
        'Binding ListBox Control
        lstGenInfo.DataSource = myDataset
        lstGenInfo.DisplayMember = "vw_geninfo_upd.VesselName"
        lstGenInfo.ValueMember = "vw_geninfo_upd.VesselLocationID"
        ''Binding the Textbox Control
        lblGenInfoID.DataBindings.Add"text",myDataset, "vw_geninfo_upd.VesselLocationID")
        txtGILatitude.DataBindings.Add("text", myDataset, "vw_geninfo_upd.LocationX")
        txtGILongitude.DataBindings.Add("text", myDataset, "vw_geninfo_upd.LocationY")
        txtGISeaWaterTemp.DataBindings.Add("text", myDataset, "vw_geninfo_upd.Temperature")
        txtGICurrentDirection.DataBindings.Add("text", myDataset, "vw_geninfo_upd.Current Direction")
        txtGICurrentVelocity.DataBindings.Add("text", myDataset, "vw_geninfo_upd.Current Velocity")
        cboGIWeatherCondition.DataBindings.Add("text", myDataset, "vw_geninfo_upd.Weather Condition")
        cboGISeaCondition.DataBindings.Add("text", myDataset, "vw_geninfo_upd.Sea Condition")
        txtGIRemarks.DataBindings.Add("text", myDataset, "vw_geninfo_upd.remarks")
        txtGITotalCatchToday.DataBindings.Add("text", myDataset, "vw_geninfo_upd.TCT")
        txtGITotalOnBoard.DataBindings.Add("text", myDataset, "vw_geninfo_upd.TOB")
        txtGIYF.DataBindings.Add("text", myDataset, "vw_geninfo_upd.YF")
        txtGISJ.DataBindings.Add("text", myDataset, "vw_geninfo_upd.SJ")
        txtGIAssist1.DataBindings.Add("text", myDataset, "vw_geninfo_upd.AssistedBy")

Jimmy P. Calatrava
System/Network Admin/VB.NET Programmer
RD Group of Companies
Philippines

---***---***---
Life always begin with TRUE or False
 
Old January 31st, 2005, 08:34 AM
Authorized User
 
Join Date: Dec 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks from Rahul Gupta






Similar Threads
Thread Thread Starter Forum Replies Last Post
datareader MunishBhatia ASP.NET 2.0 Professional 2 October 17th, 2007 07:05 AM
regarding datareader adityamadisetty VB.NET 1 May 8th, 2006 09:31 AM
DataReader truongnnhat ASP.NET 1.0 and 1.1 Basics 2 February 18th, 2005 12:41 AM
datareader surapongmax ADO.NET 1 October 8th, 2004 07:53 AM
DataReader cjcd BOOK: Beginning ASP.NET 1.0 2 March 21st, 2004 01:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.