Click here to Skip to main content
15,911,646 members
Home / Discussions / C#
   

C#

 
QuestionHelp on FTP client server socket prog Pin
satya01-Feb-06 4:57
satya01-Feb-06 4:57 
AnswerRe: Help on FTP client server socket prog Pin
Tom Wright1-Feb-06 5:05
Tom Wright1-Feb-06 5:05 
GeneralRe: Help on FTP client server socket prog Pin
satya01-Feb-06 5:10
satya01-Feb-06 5:10 
GeneralRe: Help on FTP client server socket prog Pin
Dan Neely1-Feb-06 5:36
Dan Neely1-Feb-06 5:36 
AnswerRe: Help on FTP client server socket prog Pin
Ravi Bhavnani1-Feb-06 6:25
professionalRavi Bhavnani1-Feb-06 6:25 
Question[Message Deleted] Pin
somebody_tr1-Feb-06 4:48
somebody_tr1-Feb-06 4:48 
AnswerRe: Who Will Answer it? Pin
Ingo1-Feb-06 21:43
Ingo1-Feb-06 21:43 
QuestionProper usage of SqlCommand Pin
MrEyes1-Feb-06 4:48
MrEyes1-Feb-06 4:48 
Hello,

I have a method that executes the given SqlCommand and returns the command result as a DataSet, while the method works under heavy load SQL Server (2000 Enterprise SP3) memory usage goes through the roof.

After some investigation I found that connections were being left active in the database. "Proof" of this was found after running a load test, a few minutes after the test completes (and while there is not activity on the SQL server) SQL Profiler shows various "Audit Logout" entries

EventClass : Audit Logout
TextData :
ApplicationName : LoadTestRun1
NTUserName : NETWORK SERVICE
LoginName : sa
CPU : 0
Reads : 10
Writes : 0
Duration : 459920
ClientProcessID : 0
Spid : 2969
StartTime : 2006-02-01 15:16:12.987


After hunting around various sites and tutorials this is the SqlCommand execution method:

public static DataSet ExecuteSqlCommand(SqlCommand command, string dataSetName)
{
 //argument validation
 if (command == null)
 {
  throw new ArgumentNullException("command");
 }

 if (dataSetName == null)
 {
  throw new ArgumentNullException("dataSetName");
 }

 //set dataset values
 DataSet returnDataSet = new DataSet();
 returnDataSet.DataSetName = dataSetName;
 returnDataSet.Locale = CultureInfo.InvariantCulture;

 try
 {
  SqlDataAdapter sda = new SqlDataAdapter(command);
  sda.Fill(returnDataSet);
  sda.Dispose();
  sda = null;

  return returnDataSet;
 }
 catch
 {
  throw;
 }
 finally
 {
  //cleanup resources and connections
  if (command.Connection.State != ConnectionState.Closed)
  {
   command.Connection.Close();
  }

  command.Connection.Dispose();
  command.Connection = null;
  command.Dispose();
  command = null;
 }
}


Can anybody tell me if there is anything obviously wrong with my implementation or if there is something else I should check for.
AnswerRe: Proper usage of SqlCommand Pin
ToddHileHoffer1-Feb-06 5:17
ToddHileHoffer1-Feb-06 5:17 
GeneralRe: Proper usage of SqlCommand Pin
Colin Angus Mackay1-Feb-06 5:52
Colin Angus Mackay1-Feb-06 5:52 
GeneralRe: Proper usage of SqlCommand Pin
ToddHileHoffer1-Feb-06 6:33
ToddHileHoffer1-Feb-06 6:33 
QuestionHaving a problem with this byte array Pin
Tom Wright1-Feb-06 4:40
Tom Wright1-Feb-06 4:40 
AnswerRe: Having a problem with this byte array Pin
Guffa1-Feb-06 6:50
Guffa1-Feb-06 6:50 
GeneralRe: Having a problem with this byte array Pin
Tom Wright1-Feb-06 8:59
Tom Wright1-Feb-06 8:59 
GeneralRe: Having a problem with this byte array Pin
S. Senthil Kumar1-Feb-06 18:52
S. Senthil Kumar1-Feb-06 18:52 
GeneralRe: Having a problem with this byte array Pin
Tom Wright2-Feb-06 4:20
Tom Wright2-Feb-06 4:20 
QuestionGUI Invokation problem Pin
rnvrnv1-Feb-06 4:38
rnvrnv1-Feb-06 4:38 
AnswerRe: GUI Invokation problem Pin
Tom Wright1-Feb-06 5:02
Tom Wright1-Feb-06 5:02 
GeneralRe: GUI Invokation problem Pin
rnvrnv1-Feb-06 22:11
rnvrnv1-Feb-06 22:11 
QuestionSecurity Error Pin
Drew McGhie1-Feb-06 4:16
Drew McGhie1-Feb-06 4:16 
QuestionStartup problem Pin
NewbieDude1-Feb-06 3:58
NewbieDude1-Feb-06 3:58 
Question[Message Deleted] Pin
cassie11-Feb-06 2:43
cassie11-Feb-06 2:43 
AnswerRe: why does my C# Code not work Pin
Dan Neely1-Feb-06 3:27
Dan Neely1-Feb-06 3:27 
GeneralRe: why does my C# Code not work Pin
cassie11-Feb-06 4:07
cassie11-Feb-06 4:07 
AnswerRe: why does my C# Code not work Pin
Guffa1-Feb-06 4:34
Guffa1-Feb-06 4:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.