Hi All,
I've got a loop that executes the stored procedure in a loop with over 40,000 iterations, like so:
SqlCommand command = new SqlCommand("WriteDataToDB");
command.Connection = _connection;
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@SignalID", SqlDbType.Int).Value = Arg_Si...
A little background:
I have a Windows .NET application that is in use by approximately 40 field employees across North America. This program allows the users to enter data while in the field (away form internet access) and then synchronizes to our Sql Server 2005 database at night. A couple days ago, two of my users reported getting t...
Hi all!
I'm trying do build an application using the pocket pc emulator...
My goal is to connect to a sqlserver express db placed onto another pc
note that in a simple desktop program everything works fine, but in the smartphone program, when this code is run:
SqlConnection DatabaseConnection = new SqlConnection(@"Data source=SERVER\SQL...
Hey, I currently have this method in my code:
public static DataSet PrepareDataSet(some params)
{
SqlConnection sqlConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter adapter = new SqlDataAdapter(Utils.EscapeProcedureName(...), sqlConnection);
adapter.SelectCommand.CommandTyp...
I need to execute a stored procedure in the DB every time a connection is created/opened. So I though I could handle the state change event of dbconnection/sqlconnection.
Is there a way to handle them globally? I dont know where the connections are opened in my program, so I dont have access to the sql connection objects individually.
...
Hi!
Which pattern is better for SqlConnection object? Which is better in performance?
Do you offer any other pattern?
class DataAccess1 : IDisposable
{
private SqlConnection connection;
public DataAccess1(string connectionString)
{
connection = new SqlConnection(connectionString);
}
public void Execute(stri...
I just tried to make a simple schema change to a table in a SQL Server database (by using the Design tool in SMSS). Whenever I tried to save the change, it kept timing out. I wondered whether this was due to existing connnections which were 'locking' the table.
I decided to kill connections as an experiment. I queried master..sysprocess...
In a pre-WCF .NET (C#) web service, I have an expensive IDisposable resource that I'm holding a static (actually ThreadStatic) reference to. (Internally it holds a SqlConnection.) How can I insure that this is disposed when the app pool refreshes, should I simply suppress the FxCop warning and not worry about it, or is there a third opti...
I'm really confused on how to go about doing this.
- I want to be able to upload an excel sheet from my web app using the fileupload control.
- Next, I want to read each individual row under the first row. (so starting from row 2, row 1 will be the column title).
- Finally, I want to pass the Strings I've read into another method that'll...
I have some code that I want to execute as follows. But I keep getting the exception "This SqlTransaction has completed; it is no longer usable" on the 2nd iteration. Could someone help me point out what I am doing wrong here? Thanks!
SqlConnection cn = (SqlConnection)SqlConnectionManager.Instance.GetUserConnection(user);
cn.Open()...
I use the using statement for SqlConnection. It's is good for performance because forces calling Dispose() that simply releases the connection to the pool sooner.
However, I realized that object created in using cannot be redefined. I cannot do like this:
using (SqlConnection connection = new SqlConnection(connectionString))
{
...
Disclaimer: I know IDisposable should be implemented when dealing with unmanaged resources. The rest of the code should be deterministic and do using (...) { } (equivalent of try {} finally { Dispose(); }) to guarantee a cleanup as soon as possible. Also, the GC will not call Dispose(), so the recommended pattern is to override the Fin...
I found this piece of code in one application
Database database = DatabaseFactory.CreateDatabase("connection string");
DbConnection connection = database.CreateConnection();
connection.Open();
SqlConnection sqlConnection = (SqlConnection)connection;
Is it safe, SqlConnection derieve from DbConnection. Database comes from Microsoft.Pra...
Hi everyone:
I wrote an test case extending the Spring.Net's AbstractTransactionalDbProviderSpringContextTests class and trying to do something like this.
Step.1 MyHibernateDao.Find(id)
Step.2 Use SqlConnection API to insert some record into database.
Either step.1 or step.2 can run successfully, but if I put them together, step.2 wi...
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?...
My VB WPF app is using strongly typed datasets. The connection string is set in the app.config file and is changed via the application settings designer gui. During development I connect to the test database on another server. I want a screen indicator to make it clear that the app is connected to test data.
I know I could parse the co...
Hello
I create SqlConnection objects in every Insert,Update,Delete and Select methods in asp.net web pages. Then i close the connection objects in finally block. But im not sure about this is a good way. Is this a problem about connection pool?
Do you have any recommendations about how to use SqlConnection and SqlDataReader objects for...
Is it possible to edit the data returned from command.ExecuteReader, and then return that to SqlContext.Pipe.Send()? Are there any forseeable issues (I have to reset the cursor to the beginning)?
I have a .NET stored procedure that will query a table like this
(code from MSDN)
public class StoredProcedures
{
/// <summary>
///...
This is a little wierd, but I want to check if connection to my database is already open or not? How do I check that? and if open I want to be able to work with it straightaway without going through all the statements:
sqlconnection conn = new sqlconnection("string ...");
Can this be done? I know the connection string and the connecti...
I wonder, what is the reason to have this SqlCommand constructor overload:
public SqlCommand(
string cmdText,
SqlConnection connection,
SqlTransaction transaction
)
?
When I need to create an internal method that does its bit using a transaction provided as an argument, I always find it sufficient to only pass an SqlTrans...