473,327 Members | 2,007 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,327 software developers and data experts.

idatareader?

js
Hi, I want to debug the return idatareader, how to print out some fields
value? many thanks.
Apr 17 '06 #1
3 2344


Unforunately, there isn't a clean cut way to see the values in the debugger.

i'm typing this from memory, but should get you started ..........

it probably has some syntax errors, but should be correctable.
public void ShowDataReaderValues( IDataReader idr)
{
bool keepChecking = true;
int counter = 0;

if (null != idr)
{
while (idr.Read())
{
while keepChecking = true;
{
if (!idr.IsDBNull(counter))
{
object o = idr.GetValue(counter++);
Console.WriteLine (o.ToString());
}

if (counter>idr.Depth)
{
keepChecking=false;
}

}

}

}


"js" <js@so*****@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP05.phx.gbl...
Hi, I want to debug the return idatareader, how to print out some fields
value? many thanks.

Apr 17 '06 #2
js
thanks sloan...

"sloan" <sl***@ipass.net> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...


Unforunately, there isn't a clean cut way to see the values in the
debugger.

i'm typing this from memory, but should get you started ..........

it probably has some syntax errors, but should be correctable.
public void ShowDataReaderValues( IDataReader idr)
{
bool keepChecking = true;
int counter = 0;

if (null != idr)
{
while (idr.Read())
{
while keepChecking = true;
{
if (!idr.IsDBNull(counter))
{
object o = idr.GetValue(counter++);
Console.WriteLine (o.ToString());
}

if (counter>idr.Depth)
{
keepChecking=false;
}

}

}

}


"js" <js@so*****@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP05.phx.gbl...
Hi, I want to debug the return idatareader, how to print out some fields
value? many thanks.


Apr 17 '06 #3

Since I put the wrong Property.. I fixed it.. (and since you were nice
enough to say thank you)

Here is a version that works "out of the box".

(Don't forget to .Close() those datareaders as soon as you're done with them
!! )

public void ShowDataReaderValues( IDataReader idr)

{

bool keepChecking = true;

int counter = 0;

bool resultSetExists = true;//assume at least 1 result set

if (null != idr)

{

while (resultSetExists)

{

while (idr.Read())

{

keepChecking = true;//reset

counter=0;//reset

Console.WriteLine ("------------------------------");

while (keepChecking == true)

{

if (!idr.IsDBNull(counter))

{

object o = idr.GetValue(counter++);

Console.WriteLine (o.ToString());

}

if ( counter>=idr.FieldCount )

{

keepChecking=false;

}

}

}

resultSetExists = idr.NextResult(); // this will figure out if there is
another result set

}

}

}


"js" <js@so*****@hotmail.com> wrote in message
news:eH*************@TK2MSFTNGP02.phx.gbl...
thanks sloan...

"sloan" <sl***@ipass.net> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...


Unforunately, there isn't a clean cut way to see the values in the
debugger.

i'm typing this from memory, but should get you started ..........

it probably has some syntax errors, but should be correctable.
public void ShowDataReaderValues( IDataReader idr)
{
bool keepChecking = true;
int counter = 0;

if (null != idr)
{
while (idr.Read())
{
while keepChecking = true;
{
if (!idr.IsDBNull(counter))
{
object o = idr.GetValue(counter++);
Console.WriteLine (o.ToString());
}

if (counter>idr.Depth)
{
keepChecking=false;
}

}

}

}


"js" <js@so*****@hotmail.com> wrote in message
news:uG**************@TK2MSFTNGP05.phx.gbl...
Hi, I want to debug the return idatareader, how to print out some fields value? many thanks.



Apr 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tamir Khason | last post by:
As far as I understand, IDataReader, based on command recieves isClosed property when the connection closes. How to prevent it?
2
by: Vivek Sharma | last post by:
Hi There, can some one please clarify the difference between SQLDataReader and IDataReader? What are the advantages and disadvantages of each? Thanks Vivek
5
by: Gelios | last post by:
Hello All! I am going to crazy and feeling myself so stupid but I don't understand such behaviour. I have code: public int getNextAgentId() { Int32 agent_id = 0; IDataReader dr =...
4
by: Mahesh Kumar.R | last post by:
What is the difference between SqlDataReader and IDataReader ...? kindly with small example... Mahesh~
2
by: יוני גולדברג | last post by:
Hi, In few places within my code the business object pass IDataReader to the GUI. Suddenly i noticed that nowhere in the code the IDataReader is being closed. Does the data binding operation...
2
by: Larry R | last post by:
Whenever I try the following, the reader that is returned is always closed. What am I missing ? When I look at the reader in the ExecuteReader, it is fine. THen it gets closed on the returm. ...
0
by: rsdev | last post by:
Hi, I am new to ASP.NET and I am trying to build a CMS application using theBeerHouse SK. I am adapting the Datareader to collect information from an SQL database and send it to an HtmlHeader. ...
2
by: RP | last post by:
I saw a code in a class where IDataReader is used to retrieve result from query, even if only one column is to be retrieved. It uses a CommandObject with ExecuteReader but not using ExecuteScalar....
0
by: Andrus | last post by:
RDLDesigner report designer requires IDataReader for data access. To use it with Linq, I need to convert Linq projection to IDataReader. var db = new NorthwindContext(); var q = from c in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.