开发者

SqlDataReader.GetGuid with column name c#?

开发者 https://www.devze.com 2023-02-07 16:29 出处:网络
Is there a way to get a column by name and retain the SQL type information returned by SqlDataReader?

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

I only s开发者_StackOverflow中文版ee .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"));


You could always just cast the result of the SqlDataReader's indexer:

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

精彩评论

暂无评论...
验证码 换一张
取 消