sqldbtype

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

DbType equivalent to SqlDbType.Bit

社会主义新天地 提交于 2021-01-27 04:47:33
问题 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

DbType equivalent to SqlDbType.Bit

主宰稳场 提交于 2021-01-27 04:45:11
问题 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

How to deal with System.InvalidOperationException: DataReader.GetFieldType(13)? (again)

寵の児 提交于 2020-01-05 04:13:17
问题 After upgrading my ASP.NET webforms application to .NET 4.7.2 (and 4.8) and changing the underlying database server to SQL Server 2017, I started to get this exception: Exception Details: System.InvalidOperationException: DataReader.GetFieldType(13) returned null. Underlying datatype of column 13 in the dataset is GEOGRAPHY . I have researched a bit about possible causes and this are things I have tried without success. The machine should have an instance of SQL Server installed. I have it.

Convert SqlCommand Output to List<MyType>?

徘徊边缘 提交于 2019-12-30 11:22:09
问题 I am using an ADO.NET SqlCommand with a single SqlDbType.Structured parameter to send a table-valued parameter to a sproc. The sproc returns many rows, which I need to get into a strongly-Typed List of . What is the best way to convert the result set (whether DataTable from a DataAdapter or DataReader bits) into List? Thanks. 回答1: You can use LINQ with a DataReader: var list = reader.Cast<IDataRecord>() .Select(dr => new YourType { Name = dr.GetString(0), ... }) .ToList(); 回答2: The most

SqlDbType enumeration mapping - C#

血红的双手。 提交于 2019-12-12 14:06:25
问题 What value in the SqlDbType enumeration should I use for the numeric T-SQL data type? 回答1: Decimal. See this page: http://msdn.microsoft.com/en-us/library/system.data.sqltypes.aspx 回答2: I'm pretty sure that SqlDbType.Decimal is the closest. SQL Server Data Type Mappings 来源: https://stackoverflow.com/questions/1604110/sqldbtype-enumeration-mapping-c-sharp

SubSonic 2.x StoredProcedure parameter data types?

别说谁变了你拦得住时间么 提交于 2019-12-12 01:30:34
问题 From what I can see, SubSonic 2.x stored procedure parameter data types can only be of type System.Data.DbType. Is there a quick way to add System.Data.SqlDbType so we can use System.Data.SqlDbType.Structured to pass tables - ultimately to TVP's? In this particular project, all data caller functions are accessed through StoredProcedures.cs. If we switched to 3.x, does it support SqlDbType.Structured, and if so, is it a seamless integration to retain the current StoredProcedures.cs methods?

Convert SqlCommand Output to List<MyType>?

て烟熏妆下的殇ゞ 提交于 2019-12-01 10:57:07
I am using an ADO.NET SqlCommand with a single SqlDbType.Structured parameter to send a table-valued parameter to a sproc. The sproc returns many rows, which I need to get into a strongly-Typed List of . What is the best way to convert the result set (whether DataTable from a DataAdapter or DataReader bits) into List? Thanks. You can use LINQ with a DataReader: var list = reader.Cast<IDataRecord>() .Select(dr => new YourType { Name = dr.GetString(0), ... }) .ToList(); The most efficient way is using datareader: var items = new LinkedList<MyClass>(); using(var connection = GetConnection()) {

What does SqlDbType.Structured mean?

无人久伴 提交于 2019-11-30 19:52:17
From msdn website I get the following: A special data type for specifying structured data contained in table-valued parameters. It seems my code works with it and without it (pushing table to DB using stored procedure). Can someone explain what does it do - I didn't understand it from the definition. SQL Police In SQL Server, you can define stored procedures and you can pass tables as parameter. This is then called a table valued parameter . When you are programming in C#, you can pass such a table-valued parameter to the database by using the SqlDbType.Structured constant. This post shows an

What does SqlDbType.Structured mean?

帅比萌擦擦* 提交于 2019-11-30 04:21:03
问题 From msdn website I get the following: A special data type for specifying structured data contained in table-valued parameters. It seems my code works with it and without it (pushing table to DB using stored procedure). Can someone explain what does it do - I didn't understand it from the definition. 回答1: In SQL Server, you can define stored procedures and you can pass tables as parameter. This is then called a table valued parameter . When you are programming in C#, you can pass such a table