Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Casting ..no. must be less than infinity
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01279794
Message ID:
01279855
Vues:
11
>.... double Disc = rdr.GetDouble(index)
>
>Doing this (using an Index) maens that if the layout of the Table is changed, this will not work and possibly wrong data will be saved.
>
>Is there a way of using the field name in GetDouble() rather than an Index ??


Hi,
You can use DataReader.GetOrdinal() method
double Disc = rdr.GetDouble(rdr.GetOrdinal("Disc));
But it will obviously be more efficient to retrieve the index just once -e.g:
rdr = command.ExecuteReader();
int disc = rdr.GetOrdinal("Disc");
//etc for other fields. Then:
while (rdr.Read())
{
rdr.GetDouble(disc); //etc
}
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform