[IWE] C# ODBCReader questions

Barry Roomberg iwe@warhead.org.uk
Fri, 12 Jan 2007 14:43:11 -0500


On Friday 12 January 2007 2:05, Chris Rathman wrote:
> Yes.  There's a way, but it's been a while since I've done it.  When I
> get some time later, I'll try and post the method.

Take your time.
I coded around it, but would like a generic method in the future.

>
> Barry Roomberg wrote:
> > 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
> >
> > _______________________________________________
> > 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