Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 21st, 2007, 03:05 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default to display the records using vb.net

I am new to vb.net and trying to display the records in a sequential manner from sqlserver, but only the last record is displayed. in vb we were using rs.movenext and its not there in this. how to go about ????

While dr.Read
            TextBox1.Text = dr(0).ToString()
            TextBox2.Text = dr(1).ToString()
End While

Reply With Quote
  #2 (permalink)  
Old March 21st, 2007, 03:13 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

In ADO.NET, the Read method takes care of EOF and MoveNext at the same time. So, your code probably works as expected when it comes to the database. However, look at this:

  TextBox1.Text = dr(0).ToString()

You're overwriting the Text on each iteration. Try this instead:

  TextBox1.Text += dr(0).ToString()

This adds the data for each record to the current Text.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old March 21st, 2007, 03:49 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Now my records concatenated in the textboxes. i have 4 records in my database, except the first record all the other records are displayed together!!!!!!!!:(
suppose my records like this
       name rollno
         a 10
         b 20
         c 30
         d 40

now after using as what you told

While dr.Read()

            TextBox1.Text += dr(0).ToString()

            TextBox2.Text += dr(1).ToString()
End While

it is like

textbox1 bcd
textbox2 10203040

I want to display one record at a time......how is it possible???

Reply With Quote
  #4 (permalink)  
Old March 21st, 2007, 03:57 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What do you mean with "one record at a time"? By a user's click? Or in separate lines / controls?

In what environment is this? Windows Forms / Web Forms?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #5 (permalink)  
Old March 21st, 2007, 04:36 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is Windows Form. I want to display similar results that we display using rs.Movenext in vb, one record at a time!!!!!!i.e

i have a command button "next" when i click that only the first record

textbox1 = a
textbox2 = 10

when i click the next button again it should disply the next set of records etc......
Reply With Quote
  #6 (permalink)  
Old March 21st, 2007, 05:06 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

MoveNext doesn't do anything UI related; all it does is move the Recordset to the next record. You'll need to bind your data to a UI control somehow to display it on screen.

Search Google for

"windows forms" database databind

to get some starter articles.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #7 (permalink)  
Old March 21st, 2007, 10:12 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ,

Thanks a lot Imar :)!!!!!!! its now working.I was not aware of databinding concept and now wow its interesting to know new concepts!!!!!!!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
display messagebox in ASP.Net with VB.Net suresh_accudocs ASP.NET 1.0 and 1.1 Basics 7 November 5th, 2014 06:31 PM
how to print the records in vb.net curiaquita VB.NET 0 May 16th, 2008 09:49 AM
Display records in a table unmeshraut VB How-To 1 September 21st, 2007 12:04 PM
Way to display access records using asp.net method ASP.NET 1.0 and 1.1 Basics 4 April 25th, 2005 10:41 AM
Horizontal Records display doosti Classic ASP Databases 6 November 15th, 2004 01:07 AM



All times are GMT -4. The time now is 07:04 AM.


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