473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to retrieve all the records from database into textboxes using dataadapter

35
hello,


I want to fetch all the records from database one by one when I click on next button

I have written this code for fetching the records from database.
But it shows only first record.
What code I have to written so that all the records can be fetch into textboxes.

SqlDataAdapter da = new SqlDataAdapter("select * from detail",conn1);
DataSet ds = new DataSet();

da.Fill(ds);


txtname.Text =ds.Tables[0].Rows[0][0].ToString();
txtroll.Text =ds.Tables[0].Rows[0]["roll no"].ToString();
Dec 18 '06 #1
4 7771
Hi,

For maintaining the index you could keep one variable,
on 'next' button press, increment it,
on 'prev' button press, decrement it.
don't forget to check bounds (less than zero and more than max limit).

and just update the textbox text with new values by using [index] instead of [0] in your code.

hope this helps.

Jay.
Dec 18 '06 #2
muskan
35
I have taken the index instead of 0 but it is not showing all the records

Could u give me hint by writing some code.

Hi,

For maintaining the index you could keep one variable,
on 'next' button press, increment it,
on 'prev' button press, decrement it.
don't forget to check bounds (less than zero and more than max limit).

and just update the textbox text with new values by using [index] instead of [0] in your code.

hope this helps.

Jay.
Dec 18 '06 #3
declare an int global..
private static int i =0;

at next u increment and at back u decrement it..

txtname.Text =ds.Tables[0].Rows[i][0].ToString();
txtroll.Text =ds.Tables[0].Rows[i]["roll no"].ToString();

this might help u..

I have taken the index instead of 0 but it is not showing all the records

Could u give me hint by writing some code.
Dec 18 '06 #4
kenobewan
4,871 Expert 4TB
IMO - you could use an sqldatareader ADO.NET: Retrieve Data from SQL Server

Hope that this helps.
Dec 18 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
28
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
4
by: Claudia Fong | last post by:
Hi, I have a form where I need to display the data of a department that stores in a access db. When I first load the form it will call a function name loaddata which will get the first...
12
by: jaYPee | last post by:
I have currently using a dataset to access my data from sql server 2000. The dataset contains 3 tables that is related to each other. parent/child/grandchild relationship. My problem is it's very...
2
by: jaYPee | last post by:
I have no problem setting the selectcommand in sqldataadapter to fetch record from sqlserver w/ where clause in parent table. however, my problem is on how can i fetch the child table which is...
1
by: Jean Christophe Avard | last post by:
Hi! I am designing an application, and I need some pointers. I have a database that has 5 tables: a table "Items" and 4 other table that has relationship to "Item". I have to retreive all the...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
1
by: jyothi1105 | last post by:
Hi Guys, I need your help on retrieving data from DB. Iam working on WebAppl with VB.net and SQL 2000. I want to fill my form(textboxes) with details from the database table when the user...
4
by: LetMeDoIt | last post by:
Greetings, I'm using ASP to retrieve from MSSQL and I then populate a table. After several months of successfull retrieves, this same code now bombs out. It turns out that if I clear out from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.