sqlconnection

Does SqlConnection processes queries in parallel?

和自甴很熟 提交于 2019-12-09 16:28:27
问题 If I open a SqlConnection to a SQL Server, and then issue multiple queries from multiple background threads, all using that one connection - will those queries be executed sequentially (don't care about the order)? Specifically, if at the beginning of one query I change isolation level and then restore it at the end of that query - is there a chance that this isolation level may apply to other queries? I think not, but want to confirm. SQL Server 2008 R2 And I am talking about System.Data

.net SqlConnection not being closed even when within a using { }

僤鯓⒐⒋嵵緔 提交于 2019-12-09 08:05:52
问题 Please help! Background info I have a WPF application which accesses a SQL Server 2005 database. The database is running locally on the machine the application is running on. Everywhere I use the Linq DataContext I use a using { } statement, and pass in a result of a function which returns a SqlConnection object which has been opened and had an SqlCommand executed using it before returning to the DataContext constructor.. I.e. // In the application code using (DataContext db = new DataContext

Should you reuse SqlConnection, SqlDataAdapter, and SqlCommand objects?

空扰寡人 提交于 2019-12-08 19:46:12
问题 I'm working with a DAL object that is written in a layout similar to the following code. I simplified a lot of the code code just to show the setup. public class UserDatabase : IDisposable { private SqlDataAdapter UserDbAdapter; private SqlCommand UserSelectCommand; private SqlCommand UserInsertCommand; private SqlCommand UserUpdateCommand; private SqlCommand UserDeleteCommand; private System.Data.SqlClient.SqlConnection SQLConnection; public UserDatabase() { this.SQLConnection = new System

SQL connection to localhost

拟墨画扇 提交于 2019-12-08 12:54:54
问题 I install DENWER and with help of built-in PhpMyAdmin create a database on localhost. When i connect to database in my C# application i get "SQL Exception was unhandled". Dont understand where is my mistake... Code: SqlConnection connection = new SqlConnection("Data Source=localhost; User Id=root; Password=; Initial Catalog=MyDB"); connection.Open(); 回答1: Since phpMyAdmin is a MySQL administration tool, I assume you've actually installed MySQL. Obviously you should check that you have a

SqlConnection in C#

£可爱£侵袭症+ 提交于 2019-12-07 09:21:28
问题 In VB.NET I can use: Protected Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("Active").ConnectionString) However, when I do the following in C#: protected SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings("conn")); I get the error: The name 'ConfigurationManager' does not exist in the current context Then if I change it to: protected SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("conn")); I get

How To Access Azure Function App ConnectionString Using dotnet Standard

旧街凉风 提交于 2019-12-07 06:12:36
问题 My Azure Function App has a ConnectionString defined. I want to retrieve it from a C# function written in dotnet standard 2.0. I have tried adding System.Configuration.ConfigurationManager to the project.json and using var str = ConfigurationManager.ConnectionStrings["my string"].ConnectionString; but I get the error run.csx(24,15): error CS0103: The name 'ConfigurationManager' does not exist in the current context How do I access the connection string? 回答1: ConfigurationManager is not

Does .Net do clever connection management like PHP?

喜夏-厌秋 提交于 2019-12-06 14:53:14
问题 During an ASP.NET page load I'm opening and closing multiple System.Data.SqlClient.SqlConnections inside multiple controls contained in the page. I thought it would be a good idea instead to create a "pool" of connections and when opening a connection check to see if the connection string matches that of an open connection in the pool, and return that connection. I was expecting to see a difference in the page load times, but I haven't seen any change. I know that with PHP if you attempt to

Diagnosing SqlConnection leaks?

有些话、适合烂在心里 提交于 2019-12-06 09:46:31
问题 I'm running into an issue with a web application that is exhausting all available connections in the connection pool. I seem to recall some good tools used to diagnose all active connections, but am drawing a blank. What are some good options for diagnosing this issue? 回答1: .Net memory profiler of WinDbg with SOS will allow you to track down who is holding references to your connection objects, with that information you should be able to track down the offending methods. 回答2: Are you using

Unrecognized escape sequence in SqlConnection constructor

扶醉桌前 提交于 2019-12-06 01:38:58
问题 when ever I make connection it gives an error Unrecognized escape sequence. NEPOLEON\ADMN HERE ON THIS SLASH. NEPOLEON\ADMN IS MY SQL SERVER NAME. SqlConnection con = new SqlConnection("Server=NEPOLEON\ADMN;Database=MASTER;Trusted_Connection=True"); 回答1: Escape the \ character like : SqlConnection con = new SqlConnection("Server=NEPOLEON\\ADMN;Database=MASTER;Trusted_Connection=True"); or SqlConnection con = new SqlConnection(@"Server=NEPOLEON\ADMN;Database=MASTER;Trusted_Connection=True");

Azure Functions static SqlConnection - right way to scale?

瘦欲@ 提交于 2019-12-05 20:41:22
I'm using Azure Functions with queue triggers for part of our workload. The specific function queries the database and this creates problems with scaling since the large concurrent number of function instances pinging the db results in maximum allowed number of Azrue DB connections being hit constantly. This article https://docs.microsoft.com/en-us/azure/azure-functions/manage-connections lists HttpClient as one of those resources that should be made static. Should database access also be made static with static SqlConnection to resolve this issue, or would that cause some other problems by