[IWE] C# ODBCReader questions
Barry Roomberg
iwe@warhead.org.uk
Fri, 12 Jan 2007 13:08:40 -0500
On Friday 12 January 2007 11:52, Chris Rathman wrote:
> You access it either way. Rs["Example"] or Rs[n]. Accessing by index
> is faster since it doesn't have to do a dictionary search.
You misunderstand.
I don't KNOW the field names at that point.
This is the result of a "select *".
And my goal is to assign them the a hash, by field name.
So, is there a way of getting the list of field names in it?
>
> Chris.
>
> Barry Roomberg wrote:
> > Since I can get the count of fields, and I can loop throught that, is
> > there any what, given a numeric index, to determine the name of the
> > field? This would enable generaric setup / assign code.
> >
> > On Friday 12 January 2007 11:43, Chris Rathman wrote:
> >> I've used OleDbDataReader and SqlDataReader in the past, but I'm not
> >> sure of the particular type for ODBC? I put together some notes on C#
> >> that might be useful (see the section on databases):
> >>
> >> http://www.angelfire.com/tx4/cus/notes/csharp-syntax.html
> >>
> >> In general, I could have something like:
> >>
> >> ... bunch of code to set up Command....
> >>
> >> OleDbDataReader Rs = Cmd.ExecuteReader();
> >> Rs.Read();
> >> while (Rs.Read())
> >> {
> >> string example = (string)Rs["Example"];
> >> }
> >>
> >> So, the answer is likely that you want to use the associative array that
> >> corresponds to the data reader object.
> >>
> >> Chris.
> >>
> >> Barry Roomberg wrote:
> >>> If I do a "select *" in an ODBC connection, and then have the reader
> >>> pulling the data, how can I pull the assoicated field name from the
> >>> reader array? _______________________________________________
> >>> IWE mailing list
> >>> IWE@warhead.org.uk
> >>> http://lists.warhead.org.uk/mailman/listinfo/iwe
> >>
> >> _______________________________________________
> >> IWE mailing list
> >> IWE@warhead.org.uk
> >> http://lists.warhead.org.uk/mailman/listinfo/iwe
> >
> > _______________________________________________
> > IWE mailing list
> > IWE@warhead.org.uk
> > http://lists.warhead.org.uk/mailman/listinfo/iwe
>
> _______________________________________________
> IWE mailing list
> IWE@warhead.org.uk
> http://lists.warhead.org.uk/mailman/listinfo/iwe