OracleDataReader field type?

N

n4ixt

I've hunted for what should be a fairly simple answer but can't find what
should be an answer to a simple question.

I have a data reader, let's say it's declared in C# as OracleDataReader dr =
new OracleDataReader();

I do my dr.Read, then access one of the columns as
dr["FirstName"].ToString() for example. Now let's say I would instead want
to pass my various fields (aka columns) to a method.

this.DoSomething(dr["FirstName"]);
this.DoSomething(dr["LastName"]);
this.DoSomething(dr["Age"]);

for example. When I declare my DoSomething:

private void DoSomething(??? myField)

what the heck do I put for ??? In the old ADO days this would have been
Field, but I cannot for the life of me figure out what the heck to put here.
I've googled, hunted thru MSDN, books, and drank three pots of coffee but
still don't have a clue. Someone hit me with a clue-stick, please.

Thanks,

Robert
 
A

Aytaç ÖZAY

Hi,

You can use a code like this,

private void DoSomething(object x);
{

}

Because .Net Framework doesn't know that which type of a data is coming from
a DataReader that you use before. It's type is set at run time.

Have a nice work,

Aytaç ÖZAY
Software Engineer
 
N

n4ixt

Thanks, the first pass I took at the routine I did that. I wanted something
a bit more type specific though.

I wound up refactoring and instead am passing in the DataReader and a string
with the field name and working with it in the method.

Robert

Aytaç ÖZAY said:
Hi,

You can use a code like this,

private void DoSomething(object x);
{

}

Because .Net Framework doesn't know that which type of a data is coming
from a DataReader that you use before. It's type is set at run time.

Have a nice work,

Aytaç ÖZAY
Software Engineer

n4ixt said:
I've hunted for what should be a fairly simple answer but can't find what
should be an answer to a simple question.

I have a data reader, let's say it's declared in C# as OracleDataReader
dr = new OracleDataReader();

I do my dr.Read, then access one of the columns as
dr["FirstName"].ToString() for example. Now let's say I would instead
want to pass my various fields (aka columns) to a method.

this.DoSomething(dr["FirstName"]);
this.DoSomething(dr["LastName"]);
this.DoSomething(dr["Age"]);

for example. When I declare my DoSomething:

private void DoSomething(??? myField)

what the heck do I put for ??? In the old ADO days this would have been
Field, but I cannot for the life of me figure out what the heck to put
here. I've googled, hunted thru MSDN, books, and drank three pots of
coffee but still don't have a clue. Someone hit me with a clue-stick,
please.

Thanks,

Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top