Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 213
kosh Avatar asked Sep 07 '25 20:09

kosh


1 Answers

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"));
like image 149
marc_s Avatar answered Sep 09 '25 10:09

marc_s