简体   繁体   中英

SqlDataReader.GetGuid with column name c#?

Is there a way to get a column by name and retain the SQL type information returned by SqlDataReader ?

I only see .GetGuid(int column) ?

There is no separate method to get a GUID (or any of the other types) by column name directly.

What you need to do is this:

Guid someguid = dr.GetGuid(yourDataReader.GetOrdinal("your-col-name"));

您总是可以只转换SqlDataReader的索引器的结果:

Guid myGuid = (Guid)myDataReader["myColumnName"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM