sqlconnection

Sharing transactions between connections

这一生的挚爱 提交于 2019-12-12 22:05:07
问题 I have a FileShare crawler (getting permissions and dropping them somewhere for later Audit). Currently it is starting multiple threads to crawl the same folder (to speed up the process). In C#, each SqlConnection object has its own SqlTransaction , initiated by the SqlConnection.BeginTransaction() call. Here is the pseudo code of the current solution: Get list of folders For each folder get list of sub-folders For each sub folder start a thread to collect file shares Each thread will save

Creating an IDisposable class in c# which cleans up an SqlConnection when finished with

拜拜、爱过 提交于 2019-12-12 11:19:43
问题 In an answer to a previous question somebody recommended: have the SqlConnection a member variable of your class, but make the class IDisposable and dispose of the SqlConnection when the class is disposed I have put together an implementation of this suggestion (below) but wanted to check that this implementation is correct (obviously it doesn't currently do anything except open the connection but the idea is that there would be methods in there which would use the connection and which would

“using” keyword doesn't close an open SQL connection

只愿长相守 提交于 2019-12-12 10:45:58
问题 I'm referring to a post that was put on Stack Overflow a long, long time ago. Does End Using close an open SQL Connection I have a problem however. I found that using does not close the connection at all on SQL 2012 Express edition as well as SQL 2008 Developer Edition. Here is the code that I've used. The code will go through each Database and look for a specific table specified, however, when it is done, and you run an sp_who on the server, all the connections are still there. The status is

.Net SqlConnection, Server Authentication, and Certificate Pinning

a 夏天 提交于 2019-12-12 10:44:59
问题 How does one pin a certificate when using s SqlConnection ? From SqlConnection Connection String Parameter Keywords & Values, I know I can set Encrypted to true to force (encourage?) use of SSL/TLS. However, to pin a certificate, I believe we need to use ServerCertificateValidationCallback from ServicePointManager (sample code below was offered by Arne Vajhøj for HTTP/HTTPS). I'm not clear how to wire in PinCertificate (from ServicePointManager ) to SqlConnection . UPDATE: Talking with Arne

SqlConnection and TransactionScope Timeout

こ雲淡風輕ζ 提交于 2019-12-12 10:25:03
问题 I have a TransactionScope (over DTC, read committed) with a timeout of 60 minutes. In the TransactionScope I have opened the connection (I hope to enlist in the transaction) but after 30 seconds I get a timeout. In the machine.config I changed the system.transaction maxTimeout to 60 minutes. Why does the timeout occur after 30 seconds? 回答1: A SqlCommand already has a CommandTimeout property that defaults to 30 seconds. May be you are using it within your transaction. 来源: https://stackoverflow

saving object to database c#

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:46:11
问题 I'm having class Report and class Program, what I want to accomplish (no luck so far) is to send data from class Program and method SaveRep() to class Report method Save() and save it in this method. I apologize if the question is badly formulated, I am really stuck at this, please help. Thanks using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Configuration; using System.Data.SqlClient; namespace Application { class Program {

Open SqlConnection being passed as a parameter?

筅森魡賤 提交于 2019-12-12 03:49:04
问题 I ran across this bit of code (not mine) and it weirded me out a little bit. Public Overridable Function Save(ByVal UpdateUserID As Integer) As Integer Dim conn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("mcle").ToString()) Try conn.Open() Return Save(conn, UpdateUserID) Finally conn.Close() End Try End Function Public Overridable Function Save(ByVal conn As SqlConnection, ByVal UpdateUserID As Integer) As Integer If Me.activityID <> 0 Then Return SaveAct

Enforce SqlConnection to be open for specified duration

与世无争的帅哥 提交于 2019-12-12 03:39:45
问题 It seems that SqlConnections close after some period of time of inactivity. I need to be able to control for how long the connection remains open. There is a "connection timeout" and "Connection Lifetime" properties that can be configured for connections, but they do not do what I need. The problem is that our application is huge and in lots of places connections don't get closed when some screens are open. A user can open a screen, then go to lunch, then come back, then try to do something

Update database with date format

自古美人都是妖i 提交于 2019-12-12 03:08:17
问题 I found some threads here in the forum related to this problem but they didn't help me. I just want to update my database with a date value. These come from a Textfile (written there as 2014-10-02 for example). Now I tried this (which was mentioned in the other threads): String connectionQuery = form1.conString.Text; SqlConnection connection = new SqlConnection(connectionQuery); SqlCommand sqlComInsert = new SqlCommand(@"INSERT INTO [" + form1.tableName.Text + "] ([" + form1.CusId.Text + "],[

Cannot connect to Sql Server via Android Test

≯℡__Kan透↙ 提交于 2019-12-12 00:50:48
问题 I have created simple android tests with UiAutomator. In these tests I want to confirm that some data were added in the database. In my pc I can connect to the database, but in the virtual android device I get the following error: java.lang.ClassNotFoundException: Didn't find class "net.sourceforge.jtds.jdbc.Driver" on path: /system/framework/android.test.runner.jar:/system/framework/uiautomator.jar::/data/local/tmp/Tests.jar when loading the driver: Class.forName("net.sourceforge.jtds.jdbc