Am I doing something wrong?
Thanks,
Marco
public void WriteForMe(string s)
{
SqlConnection connection = new global::System.Data.SqlClient.SqlConnection();
connection.ConnectionString = global::Trader.Properties.Settings.Default.Hedge_QuotesConnectionString;
SqlCommand cmd = new SqlCommand();
cmd.Connection = connection;
using (connection)
{
using (cmd)
{
cmd.CommandText = s;
try
{
if (cmd.Connection.State == System.Data.ConnectionState.Closed) { cmd.Connection.Open(); }
cmd.ExecuteNonQuery();
}
catch (SqlException se)
{
se.Data.Clear();
}
finally
{
if (cmd.Connection != null)
{
cmd.Connection.Close();
}
}
}
}
}
---
frmsrcurl: http://msgroups.net/microsoft.public.dotnet.languages.csharp/
Your code seems to be correct. Since you are not explicitly opening a
transaction, the server will implicity use a transaction for every query
that you run with ExecuteNonQuery, which gets immediately committed by
default.
The server using more and more memory is unrelated to transactions. This
hapens when the server keeps caching pages from the database file on disk
into the cache buffer in memory. The more pages that are read from disk, the
more memory is used to keep them in cache. You can limit the memory that Sql
Server uses for this purpose; it can be changed from the Properties window
of the server in Sql Server Management Studio.
---
frmsrcurl: http://msgroups.net/microsoft.public.dotnet.languages.csharp/Problem-with-insert-commit
Anyone has any comments. Thanks,
---
frmsrcurl: http://msgroups.net/microsoft.public.dotnet.languages.csharp/Problem-with-insert-commit
It caches any page that is read or written from the data file on disk.
This means that all pages that contain the data from the inserts are cached,
as well as all the index pages that are affected, either because they are
read (for instance, to verify a unique constraint or a primary key, or to
insert the record in a clustered index) or because they are written (the
index is modified when new records are inserted). Every page that is read or
written is kept in the cache, in case that it needs to be read later on.
Marco
---
frmsrcurl: http://msgroups.net/microsoft.public.dotnet.languages.csharp/Problem-with-insert-commit