SQL Express DB performance – auto-close evil

A quote from the original post:

By default, Express Edition creates databases with the Auto Close option enabled. This option allows SQL Server to close the physical operating system files for the database when all connections to the database are closed. The advantage here is that individual workstation installations can have database files copied around as easily as document files. This is not so advantageous in a server setup, as the overhead of opening the files and starting up the database can cause poor response times.

To check this setting for an individual database, right click the database in Management Studio, choose Properties, go to the Options page, and verify the state of the Auto Close option (it should be at the top of the list). You’ll almost certainly want to set this to False for every database on a dedicated server, with the possible exception of extremely seldom used databases.

See the original post here.


JavaScript Timer Sample

var nMiliSec = 0
var timerId = null;
function StartTimer() {
  var nMins = parseFloat(document.counter.mins.value); 
  var nSecs = parseFloat(document.counter.secs.value); 
  nMins = nMins + nSecs/60;
  nMiliSec = nMins*60*1000;    
  timerId = setTimeout(“Display()”,10);
function StopTimer() {
  nMiliSec = 0;
  if (timerId) {
function Display() {
 var oRes = document.forms.counter.result;
  if (nMiliSec > 0) {
    nMiliSec -= 10;
    var cRes    
    var nMins = parseInt(nMiliSec/60/1000);
    if (nMins < 10) {
      if (nMins > 0) {
        cRes = “0”+nMins.toString();
      } else {
        cRes = “00”;
    } else {
      cRes = nMins.toString();
    cRes += “:”;
    var nSecs = parseInt((nMiliSec/1000)%60);
    if (nSecs > 0) {
      if (nSecs < 10) {
        cRes += “0”+nSecs.toString();
      } else {
        cRes += nSecs.toString();
    } else {
      cRes += “00”;
    cRes += “:”;
    var nMili = parseInt(nMiliSec-(nSecs*1000)-(nMins*60*1000))/10
    if (nMili > 0) {
      if (nMili < 10) {
        cRes += “0”+nMili.toString();
      } else {
        cRes += nMili.toString();
    } else {
      cRes += “00”;
    oRes.value = cRes;
    timerId = setTimeout(“Display()”,10)
  } else {
function MyBeep() {
  document.writeln(“<bgsound src=’Freestyler.wav’>”);
<table style=”height:100%;width:100%”><tr><td align=”center” valign=”middle” style=”height:100%;width:100%;”>
<form name=”counter”>
  Minūtes/Sekundes <input type=”text” size=”2″ name=”mins” value=”18″><input type=”text” size=”2″ name=”secs” value=”0″>
  Laiks: <input type=”text” size=”8″ name=”result”>&nbsp;
  <input type=”button” value=”Sākt” onClick=”StartTimer()”>&nbsp;
  <input type=”button” value=”Apturēt” onClick=”StopTimer()”>
Posted in JS. Tags: . Leave a Comment »

MSBuild and TFSBuild links

Workflow Tracking DB Monitor

A sample console application that lists workflows information from the WorkflowTracking database:

Workflow Tracking DB Monitor Project

Using SharpBITS to transfer (download) file

1. Add a reference to the SharpBITS.dll on your project (download from SharpBITS.NET).
2. Add multi-line TextBox named “output” to your form.
3. Add following piece of code to your form code:

public partial class BITStester : Form

BitsManager manager = null;
object jobTransferredSync = new object();
object jobFailedSync = new object();
const string fromURL = @"http://localhost/download/test.txt";
const string fileTo = @"c:/temp/test.txt";

private void BITStester_Load(object sender, EventArgs e)
	manager = new BitsManager();
	manager.OnJobTransferred += new EventHandler(OnJobTransferred);
	manager.OnJobError += new EventHandler(OnJobError);

	FileInfo file = new FileInfo(fileTo);

	BitsJob job = manager.CreateJob(file.Name, JobType.Download);

	job.NotificationFlags = NotificationFlags.JobTransferred;

	// The default retry delay was 600 seconds (10 minutes).
	job.MinimumRetryDelay = 60; // 1 min
	job.Priority = JobPriority.High;
	job.Description = "Created by BITStester";
	job.AddFile(fromURL, fileTo);

	AddToOutput("File {0} added to BITS pool", file.Name);

private void OnJobTransferred(object sender, NotificationEventArgs e)
	lock (jobTransferredSync)
		BitsJob job = e.Job;
		AddToOutputHelper(string.Format("File {0} downloaded", job.DisplayName));

private void OnJobError(object sender, NotificationEventArgs e)
	lock (jobFailedSync)
		BitsJob job = e.Job;
		string errorMessage = string.IsNullOrEmpty(job.Description) ? 
				"Error description not provided" : job.Error.Description;

		AddToOutputHelper(string.Format("File download {0} failed: {1}", 
				job.DisplayName, errorMessage));

#region Output

private delegate void UpdateOutputHandler(string line);

// To call also from another thread
private void AddToOutputHelper(string line)
	if (output.InvokeRequired)
		output.Invoke(new UpdateOutputHandler(AddToOutput), line);

private void AddToOutput(string line)
	output.AppendText(line + Environment.NewLine);

private void AddToOutput(string line, params object[] param)
	output.AppendText(string.Format(line, param) + Environment.NewLine);

#endregion Output
} // class


Useful links when using BITS technology:

Posted in BITS, C#. Tags: , , , , . Leave a Comment »

How to Run PHP on Vista

After googling I found few useful links:

Great – I got running PHP on Vista Ultimate along ASPX in single Web Site by configuring as FastCGI module.

About second option (ISAPI). PHP 5 doesn’t contain such php5isapi.dll described in configuration. I suppose that it’s mentioned only for older versions of PHP.

MS SQL – Table Variables & Temporary Tables (Transact-SQL)

Temporary Tables

  • visible only in current session of SQL Server;
  • automatically droped on session close;
  • can’t have foreign key constraints;
  • are created in temporary database of SQL Server tempdb;
  • should manually drop to keep cached only in memory.
CREATE TABLE #temp (id int);

   SELECT id FROM Table1 WHERE ;

-- Use #temp data here.


Table Variables

  • if you are using SQL Server 2000 or higher;
  • always stay in memory;
  • don’t need to be dropped;
  • more flexibility.
DECLARE @temp table (id int);

   SELECT id FROM Table1 WHERE ;

-- Use #temp data here.


If you have SQL Server 2000 or higher always should use table variables.