List:MySQL and .NET« Previous MessageNext Message »
From:Reggie Burnett Date:July 5 2006 1:58pm
Subject:RE: Accessing fields using their names
View as plain text  
I will look at adding something like this to an upcoming release.  

> -----Original Message-----
> From: DG @ NEFACOMP [mailto:dg@stripped]
> Sent: Wednesday, July 05, 2006 5:59 AM
> To: dotNET @ MySQL
> Cc: Reggie Burnett
> Subject: Re: Accessing fields using their names
> 
> Hello, because there are some people who asked me to send them the
> modified file, I have uploaded it on my site.
> 
> You can access the file at
> http://nzeyimana.nefa.rw/dev/mysql/net/mysqlclient/datareader.cs
> For those who won't re-build the connector themselves I have also
> uploadead a binary at http://nzeyimana.nefa.rw/dev/mysql/net/bin/net-
> 2.0/Release/MySql.Data.dll
> 
> Please note that I am not an employee of MySQL ( The person in charge
> of this Connector at MySQL is Reggie Burnett); I just fell in love with
> MySQL since many years ago and am trying to be useful.
> So you should test these modifications as much as you can. If you find
> a problem please let me know.
> 
> 
> 
> Thanks
> Emery
> ----- Original Message -----
> From: "DG @ NEFACOMP" <dg@stripped>
> To: "dotNET @ MySQL" <dotnet@stripped>
> Cc: "Reggie Burnett" <reggie@stripped>
> Sent: Monday, July 03, 2006 19:12
> Subject: Accessing fields using their names
> 
> 
> > Hello group,
> >
> > While using Connector/.NET to connect to MySQL I prefer accessing the
> > DataReader fields using their names.
> >
> > Like
> >   string sCustomerName = dbReader.GetString("CustomerName") ;
> >   int nSomeIntegerVariable = dbReader.GetInt32("AnIntegerField");
> >
> > I love doing it this way because I can reorder my columns without
> having
> > to change the access code.
> >
> > With the current connector, one should retreive the field Index
> (using the
> > GetOrdinal() Method) and pass that ordinal (Index) to one of the
> accessors
> > to get the value of the column.
> > I have been doing that but I found it cumbersome and decided to add
> some
> > methods in the DataReader Class.
> >
> > The methods I added are:
> >
> > ================
> > public bool GetBoolean(String name)
> > public byte GetByte(String name)
> > public long GetBytes(String name, long dataIndex, byte[] buffer, int
> > bufferIndex, int length)
> > public char GetChar(String name)
> > public long GetChars(String name, long fieldOffset, char[] buffer,
> int
> > bufferoffset, int length)
> > public String GetDataTypeName(String name)
> > public MySqlDateTime GetMySqlDateTime(String name)
> > public DateTime GetDateTime(String name)
> > public Decimal GetDecimal(String name)
> > public double GetDouble(String name)
> > public Type GetFieldType(String name)
> > public float GetFloat(String name)
> > public Guid GetGuid(String name)
> > public Int16 GetInt16(String name)
> > public Int32 GetInt32(String name)
> > public Int64 GetInt64(String name)
> > public String GetString(String name)
> > public TimeSpan GetTimeSpan(String name)
> > public object GetValue(String name)
> > public UInt16 GetUInt16(String name)
> > public UInt32 GetUInt32(String name)
> > public UInt64 GetUInt64(String name)
> > public bool IsDBNull(String name)
> > ================
> > In the XML comments of each of these methods I added a line saying
> that
> > ordinal based lookups are faster.
> >
> > If any of you is interested in them, just drop me a message and I
> will
> > send the file over to you.
> > Also, I would like to ask Reggie why he decided to not add them in
> the
> > distributed Connector/.Net
> > OK, I have realised that Microsoft also doesn't have those in the
> > documentation while they used to exist in Visual Studio 2005 Express
> > (don't remember the exact version).
> >
> >
> >
> > Thanks
> > NZEYIMANA Emery Fabrice
> >
> > --
> > MySQL on .NET Mailing List
> > For list archives: http://lists.mysql.com/dotnet
> > To unsubscribe:
> http://lists.mysql.com/dotnet?unsub=1
> >
> >
> >


Thread
Accessing fields using their namesDG @ NEFACOMP3 Jul
  • Re: Accessing fields using their namesDG @ NEFACOMP5 Jul
    • RE: Accessing fields using their namesReggie Burnett5 Jul