DbType equivalent to SqlDbType.Bit

烂漫一生 提交于 2021-01-27 04:47:34

问题


Does anyone know what is the DbType equivalent to SqlDbType.Bit?

I am trying to convert

param[0] = new SqlParameter("@Status", SqlDbType.Bit);
param[0].Value = Status;

to

db.AddInParameter(dbCommand, "@Status", <DbType dbType>, Status);

but I don't know which DbType to use to represent a single Bit. Any ideas?


回答1:


The database type bit is represented as a boolean on the server side, so the corresponding DbType value is DbType.Boolean.




回答2:


DbType.Boolean:

A simple type representing Boolean values of true or false.

SqlDbType.Bit:

Boolean. An unsigned numeric value that can be 0, 1, or null.

Their description's don't quite match up, but since Bit is described as being a Boolean, it's the most appropriate match.




回答3:


http://msdn.microsoft.com/en-us/library/system.data.sqldbtype.aspx

enum SqlDbType - Bit: Boolean. An unsigned numeric value that can be 0, 1, or null.




回答4:


From http://msdn.microsoft.com/en-us/library/fhkx04c4, I would say DbType.Boolean A simple type representing Boolean values of true or false.



来源:https://stackoverflow.com/questions/15243333/dbtype-equivalent-to-sqldbtype-bit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!