ado.net

Store the value of a query into a SQL Server variable

南楼画角 提交于 2020-06-17 09:44:57
问题 The objective of the code is to run a query dynamically and return 0 if there are no rows with data present in the columns and to return 1 if there are rows with data in the columns. This is my code for the stored procedure: ALTER proc [dbo].[usp_ColumnFieldValidator] ( @TblName nvarchar(30), @ColumnName nvarchar(30), @RetVal bit output ) as begin declare @CountOfRowsQuery as nvarchar(300) set @CountOfRowsQuery = 'select count('+quotename(@ColumnName)+') from '+quotename(@TblName)+' having

Store the value of a query into a SQL Server variable

纵然是瞬间 提交于 2020-06-17 09:44:49
问题 The objective of the code is to run a query dynamically and return 0 if there are no rows with data present in the columns and to return 1 if there are rows with data in the columns. This is my code for the stored procedure: ALTER proc [dbo].[usp_ColumnFieldValidator] ( @TblName nvarchar(30), @ColumnName nvarchar(30), @RetVal bit output ) as begin declare @CountOfRowsQuery as nvarchar(300) set @CountOfRowsQuery = 'select count('+quotename(@ColumnName)+') from '+quotename(@TblName)+' having

Connection leak (C#/ADO.NET) even though SqlConnection created with using

删除回忆录丶 提交于 2020-06-17 09:09:54
问题 I have a program that loads a large quantity of data (~800K-1M rows per iteration) in a Task running on the threadpool (see offending code sample below); no more than 4 tasks running concurrently. This is the only place in the program that a connection is made to this database. When running the program on my laptop (and other coworkers identical laptops), the program functions perfectly. However, we have access to another workstation via remote desktop that is substantially more powerful than

How to properly connect MySQL database with C# application?

喜欢而已 提交于 2020-06-12 04:36:32
问题 I am trying to connect my MySQL database with C# but it's not getting connected. I am using static string connstring = @"server=my.live.ip;userid=user;password=123;database=db_name;port=3306"; but still I am getting Authentication to host 'my.live.ip' for user 'user' using method 'mysql_native_password' failed with message: Access denied for user 'user'@'202.xxx.xxx.xxx' (using password: NO)` I have searched on it but didn't find any suitable solution(s). P.S: The live IP that I am using is

How convert a Byte[] to a data to insert a value in a varbinary(max) column in SQL Server?

拜拜、爱过 提交于 2020-05-29 08:56:14
问题 I have a object with a byte[] property, and I would like to convert this value to the correct value to can insert it into the database using T-SQL. But I don't know how I could convert the byte[] to the correct value for T-SQL for the insert. Thanks. 回答1: Create a Console Application project and try this code // Sample Class public class MyClass { public byte[] data; } // Main static void Main(string[] args) { MyClass cls = new MyClass(); using (SqlConnection cn = new SqlConnection(

How convert a Byte[] to a data to insert a value in a varbinary(max) column in SQL Server?

有些话、适合烂在心里 提交于 2020-05-29 08:56:14
问题 I have a object with a byte[] property, and I would like to convert this value to the correct value to can insert it into the database using T-SQL. But I don't know how I could convert the byte[] to the correct value for T-SQL for the insert. Thanks. 回答1: Create a Console Application project and try this code // Sample Class public class MyClass { public byte[] data; } // Main static void Main(string[] args) { MyClass cls = new MyClass(); using (SqlConnection cn = new SqlConnection(

How convert a Byte[] to a data to insert a value in a varbinary(max) column in SQL Server?

馋奶兔 提交于 2020-05-29 08:56:11
问题 I have a object with a byte[] property, and I would like to convert this value to the correct value to can insert it into the database using T-SQL. But I don't know how I could convert the byte[] to the correct value for T-SQL for the insert. Thanks. 回答1: Create a Console Application project and try this code // Sample Class public class MyClass { public byte[] data; } // Main static void Main(string[] args) { MyClass cls = new MyClass(); using (SqlConnection cn = new SqlConnection(

Fill Dataset Async

六月ゝ 毕业季﹏ 提交于 2020-04-17 23:41:30
问题 Below method is getting used to fill Dataset. if we are calling this method in synchronous way it is working fine. But now we need to call this method in Asynchronous way.so what changes i need to do so that below method should work properly without any issue. public DataSet Filldata(string ProcName, string TableName) { DataSet ds = new DataSet(); try { da = new SqlDataAdapter(ProcName, con); if (con.State != ConnectionState.Open) { con.Open(); } da.SelectCommand.CommandTimeout = 15000; da

Entity Framework, TPT Inheritance and Multi-Language support

ε祈祈猫儿з 提交于 2020-04-15 17:17:04
问题 I have this DB Structure: Service Id int PK CategoryId FK SomeOtherFields LocalizedService LocalizedServiceId PK LanguageId FK Name Description As you can see, I have a base table called Service, and a LocalizedService table in which I'm writing multilingual data, such as name and description which should be translated in different languages. I have linked both tables in EF designer using TPT inheritance. Service is a base class of LocalizedService. The problem is that, TPT requires both

Entity Framework, TPT Inheritance and Multi-Language support

不问归期 提交于 2020-04-15 17:16:25
问题 I have this DB Structure: Service Id int PK CategoryId FK SomeOtherFields LocalizedService LocalizedServiceId PK LanguageId FK Name Description As you can see, I have a base table called Service, and a LocalizedService table in which I'm writing multilingual data, such as name and description which should be translated in different languages. I have linked both tables in EF designer using TPT inheritance. Service is a base class of LocalizedService. The problem is that, TPT requires both