vendredi 11 mai 2007

"New schema comparison" display corrupted

What an interesting "annoyance".

I just wanted to do a new "schema comparison" with VSTS for Db Professional and found this :


Detail of the drop down :

How am I supposed to pick the right db on the right server ???

Let's MsdnForum it.

vendredi 16 mars 2007

DbCommand - SqlCommand : Best Practice

DON'T :

string connectionString="..."

SqlConnection sqlCon = new SqlConnection(connectionString);
SqlCommand sqlCmd = sqlCon.CreateCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.CommandText = "...";
SqlParameter sqlPar = sqlCmd.CreateParameter();
sqlPar.ParameterName = "...";

DO :

string connectionString="..."
DbConnection dbCon = new SqlConnection(connectionString);
IDbConnection dbCon = new SqlConnection(connectionString);
DbCommand dbCmd = dbCon.CreateCommand();
IDbCommand dbCmd = dbCon.CreateCommand();
dbCmd.CommandType = CommandType.StoredProcedure;
dbCmd.CommandText = "...";
DbParameter dbPar = dbCmd.CreateParameter();
IDataParameter dbPar = dbCmd.CreateParameter();
dbPar.ParameterName = "...";

The goal of this is to limit the amount of provider-specific code.
If you want to adapt this code for any other provider (OleDb, ODBC, Oracle,...) , you only have to change it in 1 place.

Mmm. This is what M$ recommends.
Maybe I should do some test with it to see whether there are any perfs impact...
Maybe more on that someday...

DataTable.Copy() <> DataTable.Clone()

If you want to copy a datatable schema with it's info, do :
DataTable.Copy()

If you only need to copy the schema without the info specified in the datarow, do :
DataTable.Clone()

As specified on msdn : http://msdn2.microsoft.com/en-us/library/system.data.datatable.clone.aspx

Both the Copy and the Clone methods create a new DataTable with the same structure as the original DataTable. The new DataTable created by the Copy method has the same set of DataRows as the original table, but the new DataTable created by the Clone method does not contain any DataRows.

mardi 13 mars 2007

ToggleCSharpNavigationBar update

While ToggleCSharpNavigationBar is great when having performance as a goal, it wasn't completely doing stuff I wanted so I updated it.

So now, it deactivate the navigation bar in .CS, .HTML & .ASPX

Sub ToggleCSharpNavigationBar()

'for DBG purposes
'If (InputBox("File", "", DTE.ActiveDocument.Name & DTE.ActiveDocument.Kind)) = "" Then Return

Dim objShowNavigationBar As EnvDTE.Property

Dim setProp As Boolean 'whether props have been set

setProp = True

Dim kindDoc As String

kindDoc = DTE.ActiveDocument.Kind

Dim fileName As String

fileName = DTE.ActiveDocument.Name.ToLower()

Select Case kindDoc

Case "{8E7B96A8-E33D-11D0-A6D5-00C04FB67F6A}" 'This kind is for "text" files VB, CS, XML...

If fileName.EndsWith(".cs") Then
objShowNavigationBar = DTE.Properties("TextEditor", "CSharp").Item("ShowNavigationBar")
Else
setProp = False
End If

Case "{57312C73-6202-49E9-B1E1-40EA1A6DC1F6}" 'ASPX

objShowNavigationBar = DTE.Properties("TextEditor", "HTML").Item("ShowNavigationBar")

Case "{C76D83F8-A489-11D0-8195-00A0C91BBEE3}" 'HTML

objShowNavigationBar = DTE.Properties("TextEditor", "HTML").Item("ShowNavigationBar")

Case Else

setProp = False

End Select

If (setProp) Then objShowNavigationBar.Value = Not objShowNavigationBar.Value

End Sub

mercredi 7 mars 2007

Easier solution for Get Specific version ?

Right-click on toolbar area.
Tick "Source control - Team Foundation"
and :
Let me introduce you, from left to right
  • "Change source control"
  • "Get latest version"
  • "Get specific version"
  • "Check out for edit"
  • "Check in "
  • "Undo pending changes"
  • "View history"
  • "Refresh status"

Get Specific version on Solution folder

Solution folders seemed to be a nice feature.


Alas, the only way to do a get (latest) version for project under it was to do it on every project.

What a pain.

Just by using "Customize", I added the "Get latest version" button.
This didn't work. Because TFS is not a "standard" source control.

Luckily TFS has added a new buttons :


Just added it to my "Standard" toolbar and "Voilà" !

I also added the great advice from Mr GhostDoc himself !

mardi 6 mars 2007

GetCurrentProcessInfo() and IIS6

Process metrics are available only when the ASP.NET process model is enabled. When running on versions of IIS 6 or newer in worker process isolation mode, this feature is not supported.
at System.Web.ProcessModelInfo.GetCurrentProcessInfo()
at ...

Nice feature.

Every web application we have use the same logging technique :
ProcessInfo piUser = ProcessModelInfo.GetCurrentProcessInfo();
swLogFile.WriteLine("{0} - Process ID {1} started at {2} - Memory peak : {3}", dtNow.ToLongTimeString(), piUser.ProcessID, piUser.StartTime, piUser.PeakMemoryUsed);
swLogFile.WriteLine("{0} - Status : {1}", dtNow.ToLongTimeString(), piUser.Status);
swLogFile.WriteLine("{0} - Shutdown Reason : {1}", dtNow.ToLongTimeString(), piUser.ShutdownReason);
swLogFile.WriteLine("{0} - Method : {1}", dtNow.ToLongTimeString(), ProcedureName);
swLogFile.WriteLine("{0} - Message : {1}", dtNow.ToLongTimeString(), e.Message);
swLogFile.WriteLine("{0} - Detailled error file : {1}", dtNow.ToLongTimeString(), WriteErrorLog(e));


On all our W2k web servers, this works well.
On all the WXP dev stations this works well.
On the new W2k3 web server, this fails miserably.

So we just have to change it to this :

try
{ piUser = ProcessModelInfo.GetCurrentProcessInfo(); }
catch
{//We're not running under ASP.NET process model.
piUser = null;
}


And make sure that the Append to StreamWriter doesn't want to access
piUser.ProcessID