sqlclient

Unable to connect to sql database using System.Data.SqlClient 4.4.3 and hostname but ip works

Deadly 提交于 2020-08-09 08:15:44
问题 I have tried running this in a asp.net core 3.1 app inside a docker container based on mcr.microsoft.com/dotnet/core/sdk:3.1-bionic (Ubuntu 18.04). also tried with mcr.microsoft.com/dotnet/core/sdk:3.1-buster. I'm trying to connect to a database with the following code: using var connection = new SqlConnection(connectionString); connection.Open(); If i use an ip adress it works fine. If i run this outside of a docker container it works fine. If i run in a container and use System.Data

Unable to connect to sql database using System.Data.SqlClient 4.4.3 and hostname but ip works

南笙酒味 提交于 2020-08-09 08:15:35
问题 I have tried running this in a asp.net core 3.1 app inside a docker container based on mcr.microsoft.com/dotnet/core/sdk:3.1-bionic (Ubuntu 18.04). also tried with mcr.microsoft.com/dotnet/core/sdk:3.1-buster. I'm trying to connect to a database with the following code: using var connection = new SqlConnection(connectionString); connection.Open(); If i use an ip adress it works fine. If i run this outside of a docker container it works fine. If i run in a container and use System.Data

Why can't I set properties or use attributes in C# anonymous types?

懵懂的女人 提交于 2020-01-06 19:45:10
问题 C# anonymous types seem really useful, but I've pretty immediately hit upon an application where I would like to set the property of an anonymous type, and I'd also like to be able to use attributes. My application is a general purpose stored procedure and SQL executor, which can automatically map C# properties to SQL input and output paramaters with appropriate SqlDbType (e.g. string maps to NVARCHAR(MAX) , etc.). e.g. int PersonID = 1234; var output = new { GivenName = (string)null,

How can I get inserted ID in SQL Server while using SqlClient class?

丶灬走出姿态 提交于 2020-01-02 07:05:30
问题 So this is a continuation of post: Best way to get identity of inserted row? That post proposes, and I agree, to use Inserted feature to safely return inserted id column(s). While implementing this feature, it seems SqlClient of the .net framework does not support this feature, and fails while trying to execute command, I get the following exception: System.Data.SqlClient.SqlException: 'Cannot find either column "INSERTED" or the user-defined function or aggregate "INSERTED.Id", or the name

How can I get inserted ID in SQL Server while using SqlClient class?

久未见 提交于 2020-01-02 07:05:13
问题 So this is a continuation of post: Best way to get identity of inserted row? That post proposes, and I agree, to use Inserted feature to safely return inserted id column(s). While implementing this feature, it seems SqlClient of the .net framework does not support this feature, and fails while trying to execute command, I get the following exception: System.Data.SqlClient.SqlException: 'Cannot find either column "INSERTED" or the user-defined function or aggregate "INSERTED.Id", or the name

Scope_identity() in batched sqlclient commands

北城余情 提交于 2019-12-31 05:01:06
问题 I usually use a stored procedure when inserting records to make sure I get the correct scope_identity() value. I have a requirement to get the id field of an inserted record when using SqlClient now. My understanding is that if I batch the scope_identity() command with the insert then it will still be in the same scope as the insert command? Something like below. Hard to verify though... Will I 100% get the correct id value with this..? (id field is an auto-incrementing bigint - Sql Server)

Use SqlDataReader in F#

依然范特西╮ 提交于 2019-12-29 07:44:32
问题 In C# I use sql scripts to add data into a List where T would be a class with fields/properties mapped to the sql script. How could I do this in F#? This piece uses a stored procedure in the standard way. using (conn) { conn.Open(); using (SqlCommand cmd = new SqlCommand("dbo.query_here", conn)) { cmd.CommandText = "dbo.query_here"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandTimeout = 600; cmd.Parameters.Add(new SqlParameter("@x1", Convert.ToString(x))); cmd

System.Data.SqlClient.SqlException: 'Must declare the scalar variable'

馋奶兔 提交于 2019-12-25 18:53:48
问题 I have checked other threads with related errors, but none of them pertained to my problem on a specific level. I am trying to update data via TextBox edits in a WPF form, submitted via an Update Button to the SQL database. The initial / current data is loaded when the form opens and a user is selected. It will show all the information that pertains to them on the SQL database in their corresponding TextBoxes, the problem comes into play when I want to change that loaded information and

Retrieve record counts from multiple statements

試著忘記壹切 提交于 2019-12-25 04:07:24
问题 I wrote my own SQL client because I was tired of SSMS. I want to capture the affected row counts just like SSMS but SqlCommand.StatementCompleted is raised multiple times when ExecuteReader finishes (or EndExecuteReader is called). Even though the statements in the batch complete with a regular interval, it seems like the DONE_IN_PROC messages are queued up on the client, and then dumped all at once, instead of being raised continuously. No InfoMessage events through-out the execution from

Azure functions runtime exception, the type initializer for system data sqlclient excetion, Unable to load DLL 'sni.dll'

不打扰是莪最后的温柔 提交于 2019-12-24 22:39:17
问题 I am using aspnet core 3.0 and azure function v3-preview with system.data.sqlclient version 4.7.0 When i try to run azure function(on both service queue trigger and time trigger) it gives below error : The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. The type initializer for 'System.Data.SqlClient.SNILoadHandle' threw an exception. Unable to load DLL 'sni.dll' or one of its dependencies: The specified module could not be found. I tried solutions from below links