Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 October 10th, 2007, 01:09 PM
Sjo Sjo is offline
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi there,

I tried using

hasrows = reader.Read()

then assigning reapter.datasource= reader

The first record is still missing. Is there any other way I can achieve the same feature. Since I am using IDataReader to get the resultset back from Microsoft.Enterprise.Library I dont have any other option but to use IDataReader. IDataReader doesnt have HasRows properties.

Further suggestion will be appreciable.

Thanks in advance.

 
Old October 10th, 2007, 01:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

I was reading this since a couple of days.. Why are you using a IdataReader that supposed to be only an interface and you probably has a instance of an object on top of it???

Another set of ideas would be filling a datatable from this reader and then see if the datatable has rows...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old October 10th, 2007, 02:04 PM
Sjo Sjo is offline
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Since I am using Data Access Application block for the database connectivity the return type of ExecuteReader of the DAB is IDataReader and I cannot cast it to any other DataReader Type.

The another work around to fill the reader with DataTable will also cause the record to loose. Since I am using reapter control to display, it automatically does reader.Read() so incase I use reader.Read() before assigning it to the repeater control the record will get lost.

Any other suggestion, thanks

 
Old October 10th, 2007, 02:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

I don't know why you say you lose records loading a datatable, a datatable.load will make you lost records??.. but another workaround would be to just execute a count before actually filling the datareader...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old October 10th, 2007, 02:50 PM
Sjo Sjo is offline
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Gonzalo

Thanks for your reply.

Your work around to load DataTable didn't work because when I fill DataTable with the reader and check the DataRow count and return the result, DataReader is closed by then.

Can you explain more how to check the count of DataReader before assigning? Which specific property are you trying to refer.

thanks again

 
Old October 10th, 2007, 03:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

just execute an SQL like "SELECT COUNT(*) FROM table" and it will return the number of rows of your table.. alter the SQL to the where clause you use for filling the reader...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old October 12th, 2007, 01:04 PM
Sjo Sjo is offline
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Gonzalo,

Thanks for your suggestions, I used the DataTable.Load(reader) and used the DataTable.DataRow to find a count and used the DataReader for reading and it worked absolutely fine.

It worked finally!!

Cheers!

 
Old October 12th, 2007, 05:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Glad it worked :)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





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 NitinJoshi ADO.NET 4 January 31st, 2005 08:34 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.