''Math.Round default is Banker's Rounding.''\n\nMath.Round has two modes of midpoint rounding; ToEven and AwayFromZero. ToEven is commonly known as Banker's Rounding. AwayFromZero is used by Excel and VBA. By default Math.Round uses ToEven. To tell Math.Round to mimic Excel and VBA use the MidpointRounding.AwayFromZero parameter.\n\nSimple example:\n{{{\nDim roundedAmount as Integer = Math.Round(amount, MidpointRounding.AwayFromZero).\n}}}\n\nExample of rounding to the nearest cent:\n{{{\nDim original As Decimal = 1D\nDim rounded As Decimal = 0D\n\nFor index As Integer = 1 To 9\n original += 0.001\n rounded = Math.Round(original, 2, MidpointRounding.AwayFromZero)\n Debug.Print(String.Format("Original value: {0}, Rounded value: {1}", original, rounded))\nNext index\n\nOriginal value: 1.001, Rounded value: 1.00\nOriginal value: 1.002, Rounded value: 1.00\nOriginal value: 1.003, Rounded value: 1.00\nOriginal value: 1.004, Rounded value: 1.00\nOriginal value: 1.005, Rounded value: 1.01\nOriginal value: 1.006, Rounded value: 1.01\nOriginal value: 1.007, Rounded value: 1.01\nOriginal value: 1.008, Rounded value: 1.01\nOriginal value: 1.009, Rounded value: 1.01\n}}}
''Visual Basic convert functions and their CType equivalence.''\n{{{\nCInt(expression) => CType(expression, Integer)\nCDbl(expression) => CType(expression, Double)\nCDec(expression) => CType(expression, Decimal)\nCDate(expression) => CType(expression, Date)\n}}}
''How to change a row value for an Identity column.''\n{{{\nset identity_insert [*databasename*].[dbo].[*tablename*] on\ninsert into [*databasename*].[dbo].[*tablename*] (*tableid*) values(0)\nset identity_insert [*databasename*].[dbo].[*tablename*] off\n}}}\nExample for table EmployeeActivity with an Identity column named EmployeeActivityID\n{{{\nset identity_insert [Toolbox200_0000_Nunit].[dbo].[EmployeeActivity] on\ninsert into [Toolbox200_0000_Nunit].[dbo].[EmployeeActivity] (EmployeeActivityID) values(0)\nset identity_insert [Toolbox200_0000_Nunit].[dbo].[EmployeeActivity] off\n}}}\nCredit: Ricke E. Stauffer, Jr.
''Checks the integrity of all constraints on the current database''\n{{{\nDBCC CHECKCONSTRAINTS\n}}}
''chkdsk Fixed Invalid Security ID's which Broke ASP.NET 2.0''\n{{{\nchkdsk /f c: found hundreds of file with invalid security id on Windows XP SP2 computer.\n\nchkdsk "corrected" them with this message:\n Replacing invalid security id with default security id for file NN.\n\nAfter this ASP.NET 2.0 stopped working. Error:\n The request failed with HTTP status 401: Access Denied.\n\nThe C:\sWINDOWS\ssystem32\sLogfiles\sW3SVC1\sexNNNNNN.log files contained messages like:\n 21:41:19 127.0.0.1 GET /Test/index.aspx 401\n\nAt least the following file losted its ACL:\n C:\sWINDOWS\sMicrosoft.NET\sFramework\sv2.0.50727\saspnet_wp.exe\n\nDid the following to correct the problem:\n1) Reboot computer\n\n2) Add or Remove Programs\n - Microsoft .NET Framework 2.0\n - Uninstall (Repair did not work)\n\n3) Reboot computer\n\n4) Reinstalled Microsoft .NET Framework 2.0\n - DotNetFrameworkRedist20.exe\n\n5) Ran C:\sWINDOWS\sMicrosoft.NET\sFramework\sv2.0.50727\saspnet_regiis /i\n\n6) Reboot computer\n\n7) http://update.microsoft.com/windowsupdate\n - Security Update for Microsoft .NET Framework, Version 2.0 (KB922770)\n - Security Update for Microsoft .NET Framework, Version 2.0 (KB917283)\n}}}
''Normal use and ordering of VS2005 Code Regions''\n{{{\n\n#Region " Event Definitions "\n#End Region\n\n#Region " Properties "\n#End Region\n\nPublic Sub New()\n\n#Region " Public Methods "\n#End Region\n\n#Region " Protected Methods "\n#End Region\n\n#Region " Private Methods "\n#End Region\n\n#Region " Event Handlers "\n#End Region\n}}}
{{{\nPublic Function CompareByteArrays(ByVal data1() As Byte, ByVal data2() As Byte) As Boolean\n If (data1 Is Nothing) And (data2 Is Nothing) Then\n ' Both are nothing, they're equal.\n Return True\n End If\n If (data1 Is Nothing) Or (data2 Is Nothing) Then\n ' Either but not both are nothing, they're not equal.\n Return False\n End If\n If data1.Length <> data2.Length Then\n Return False\n End If\n For index As Integer = 0 To data1.Length - 1\n If data1(index) <> data2(index) Then\n Return False\n End If\n Next index\n Return True\nEnd Function\n}}}\nBased on C# code written by Jon Skeet: http://www.dotnet247.com/247reference/msgs/46/232136.aspx
''DataRow to Business Facade Row Conversion''\n\n{{{\nDim rows() As DataRow = Me.uiCustomerFind.BFCustomerProperty.DataSet.Customer.Select( _\n "CustomerID = " & Me.uiCustomerFind.SelectedCustomerID)\nIf rows IsNot Nothing AndAlso rows.Length > 0 Then\n Dim customerRow As BODSCustomer.CustomerRow = DirectCast(rows(0), BODSCustomer.CustomerRow)\n Me.CustomerFirstName = customerRow.FirstName\n Me.CustomerLastName = customerRow.LastName\nEnd If\n}}}
''Visual Basic Date formatting.''\n{{{\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToBinary => 632721648105000000\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToLongDateString => "Friday, January 06, 2006"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToFileTime => 127810596105000000\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToFileTimeUtc => 127810416105000000\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToLocalTime => #1/6/2006 12:20:10 PM#\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToLongDateString => "Friday, January 06, 2006"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToLongTimeString => "5:20:10 PM"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToOADate => 38723.72234375\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToShortDateString => "1/6/2006"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToShortTimeString => "5:20 PM"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToString => "1/6/2006 5:20:10 PM"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToString("d") => "1/6/2006"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToString("F") => "Friday, January 06, 2006 5:20:10 PM"\n'Note; the following conforms to the ISO standard 8601.\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToString("s") => "2006-01-06T17:20:10"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToString("yyyy-MM-dd") => "2006-01-06"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToString("yyyyMMdd") => "20060106"\nNew Date(2006, 1, 6, 17, 20, 10, 500).ToUniversalTime => #1/6/2006 10:20:10 PM#\n}}}
[[Welcome]]
''Defining an Event''\n\n{{{\n#Region " Event Definitions "\nPublic Event Boo(ByVal sender As Object, ByVal e As EventArgs)\n#End Region\n\n#Region " Protected Methods "\nProtected Overridable Sub OnBoo(ByVal e As EventArgs)\n RaiseEvent Boo(Me, e)\nEnd Sub\n#End Region\n\nIn code:\nDim eArgs As New EventArgs\nOnBoo(eArgs)\n\n}}}
''Command prompt - List recursive read/write files (not read-only)''\nFrom the root of the directories to search:\n{{{\nDir /s/A-R *.vb\n}}}\n(recursive search of all .vb files set to read-write... change to *.* to list all files)\n\nCredit: Ricke E. Stauffer, Jr.
''Format Date with String class''\n\n{{{\nDim dateString as String \ndateString = String.Format("Today's date is {0:d}.", Date.Today)\n' Sample output: Today's date is 10/6/2006.\n\ndateString = String.Format("Today's date is {0:D}.", Date.Today)\n' Sample output: Today's date is Friday, October 06, 2006.\n}}}\n\n
Larry Hunt\nhuntware AT gmail DOT com
© 2006 [[huntware|http://www.huntware.com]]
''MessageBox.Show example"\n\n{{{\n' Prompt user.\nDim message As String = String.Format("Is {0} your favorite color?", "Blue")\nDim result As Windows.Forms.DialogResult = _ \n Windows.Forms.MessageBox.Show(message, "Your Favorite Color?", Windows.Forms.MessageBoxButtons.YesNo)\nIf result = Windows.Forms.DialogResult.Yes Then\n ' Guess is correct.\nElse\n ' Guess is not correct.\nEnd If\n\n}}}
Make sure you run [[newsid.exe|http://www.sysinternals.com/Utilities/NewSid.html]] after you clone a new machine. Makes Active Directory happy, (which we'll be using for the Team Foundation development) plus there may be some other unknown side effects that are prevented.\n\nCredit: Bruce Franson\n
This sample code shows how to implement Next, Previous, First and Last buttons based on an UltraCombo / SSICombo and its sort, and how to have a label displaying the current record position.\n{{{\nPrivate Sub uiBtnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiBtnFirst.Click\n Me.BindingContext()(Me.BFPayment.DataSet, "Payment").Position = Me.BFPayment.DataSet.Payment.Rows.IndexOf(DirectCast(Me.uiCmbLookupPayment.DisplayLayout.Rows.GetRowAtVisibleIndex(0).ListObject, DataRowView).Row)\nEnd Sub\n\nPrivate Sub uiBtnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiBtnPrev.Click\n Dim visibleIndex As Integer = Me.uiCmbLookupPayment.ActiveRow.VisibleIndex\n If visibleIndex > 0 Then\n Me.BindingContext()(Me.BFPayment.DataSet, "Payment").Position = Me.BFPayment.DataSet.Payment.Rows.IndexOf(DirectCast(Me.uiCmbLookupPayment.DisplayLayout.Rows.GetRowAtVisibleIndex(visibleIndex - 1).ListObject, DataRowView).Row)\n End If\nEnd Sub\n\nPrivate Sub uiBtnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiBtnNext.Click\n Dim visibleIndex As Integer = Me.uiCmbLookupPayment.ActiveRow.VisibleIndex\n If visibleIndex < (Me.uiCmbLookupPayment.DisplayLayout.Rows.VisibleRowCount - 1) Then\n Me.BindingContext()(Me.BFPayment.DataSet, "Payment").Position = Me.BFPayment.DataSet.Payment.Rows.IndexOf(DirectCast(Me.uiCmbLookupPayment.DisplayLayout.Rows.GetRowAtVisibleIndex(visibleIndex + 1).ListObject, DataRowView).Row)\n End If\nEnd Sub\n\nPrivate Sub uiBtnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiBtnLast.Click\n Me.BindingContext()(Me.BFPayment.DataSet, "Payment").Position = Me.BFPayment.DataSet.Payment.Rows.IndexOf(DirectCast(Me.uiCmbLookupPayment.DisplayLayout.Rows.GetRowAtVisibleIndex(Me.uiCmbLookupPayment.DisplayLayout.Rows.VisibleRowCount - 1).ListObject, DataRowView).Row)\nEnd Sub\n\nPrivate Sub UpdateRecordCount()\n Me.uiLblRecordCount.Text = String.Format("{0} of {1}", Me.uiCmbLookupPayment.ActiveRow.VisibleIndex + 1, Me.uiCmbLookupPayment.DisplayLayout.Rows.VisibleRowCount)\nEnd Sub\n\nPrivate Sub uiCmbLookupPayment_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles uiCmbLookupPayment.ValueChanged\n Me.UpdateRecordCount()\nEnd Sub\n}}}\nCredit: Ricke E. Stauffer, Jr.
''Some nice pastel colors''\n{{{\nLightBlue ADD8E6\nLightCoral F08080\nLightGoldenRodYellow FAFAD2\nLightGreen 90EE90\nLightGrey D3D3D3\nLightPink FFB6C1\nLightSalmon FFA07A\nLightSeaGreen 20B2AA\nLightSkyBlue 87CEFA\nLightSlateBlue 8470FF\nLightSteelBlue B0C4DE\nLightYellow FFFFE0\n}}}
''Get rid of nulls.''\n\nSearches through all tables in current database, sets all null values in the following column types to the following values:\nBigint=0\nBit = 0 \nDecimal = 0\nInt = 0 \nMoney = 0\nDatetime = 1/1/1753\nNvarchar = ' ' \nVarchar = ' '\n\nExcludes identity columns to avoid errors, and since they can’t be null anyway.\n\n{{{\ndeclare @sql nvarchar(500)\ndeclare @cname varchar(50)\ndeclare @tname varchar(50)\ndeclare @type varchar(50)\ndeclare @value varchar(50)\n\nDECLARE ccursor CURSOR\nFOR select so.name, sc.name, st.name from syscolumns sc\ninner join sysobjects so on sc.id = so.id\ninner join systypes st on sc.xtype = st.xtype\nwhere so.xtype = 'U' and sc.status & 128 <> 128 and\n (st.name = 'bigint' or \n st.name = 'bit' or\n st.name = 'datetime' or\n st.name = 'decimal' or\n st.name = 'int' or\n st.name = 'money' or\n st.name = 'nvarchar' or\n st.name = 'varchar')\n\nOPEN ccursor\nFETCH NEXT FROM ccursor \n INTO @tname, @cname, @type\n\nWHILE @@FETCH_STATUS = 0\nBEGIN \n\nif @type = 'bigint' or @type = 'int' or @type = 'bit' or @type = 'decimal' or @type = 'money'\n set @value = '0'\nif @type = 'datetime'\n set @value = '''1/1/1753'''\nif @type = 'nvarchar' or @type = 'varchar'\n set @value = ''''''\n\nset @sql = 'update ' + @tname + ' set ' + @cname + ' = ' + @value + ' where ' + @cname + ' is null'\n\nexec sp_executesql @sql\nif @@error > 0\nselect @sql\n\nFETCH NEXT FROM ccursor \n INTO @tname, @cname, @type\n\nEND\nCLOSE ccursor\nDEALLOCATE ccursor\n}}}\nCreated by Ricke E. Stauffer, Jr.\nUpdated by Dave J. Flanagan
''Get rid of stored procedures''\n{{{\nbegin transaction\n\nselect count(so.id) from sysobjects so\nwhere name like 'sp%' and xtype = 'P'\n\ndeclare @sql nvarchar(500)\ndeclare @spname varchar(50)\n\nDECLARE ccursor CURSOR\nFOR select name from sysobjects so\nwhere name like 'sp%' and xtype = 'P'\n\nOPEN ccursor\nFETCH NEXT FROM ccursor \n INTO @spname\nWHILE @@FETCH_STATUS = 0\n\nBEGIN \nset @sql = 'drop procedure ' + @spname\nexec sp_executesql @sql\nif @@error > 0\nselect @sql\n\nFETCH NEXT FROM ccursor \n INTO @spname\nEND\nCLOSE ccursor\nDEALLOCATE ccursor\n\nselect count(so.id) from sysobjects so\nwhere name like 'sp%' and xtype = 'P'\n\nrollback transaction\n}}}\nCreated by Ricke E. Stauffer, Jr.
''Attribute for No Step In While Debugging''\n\nAll simple Properties should be preceded by <System.Diagnostics.DebuggerNonUserCode()> so F11 does not by default step into the properties. If the Property Get or Set has real code in it you don’t need to add the step through attribute. There is a flag in VS Options that can be flipped so someone can step into the code if desired.\n\n{{{\n<System.Diagnostics.DebuggerNonUserCode()> _\nPublic Property Foo() As String\n Get\n Return _foo\n End Get\n Set(ByVal value As String)\n _foo = value\n End Set\nEnd Property\n}}}\n\nCreated by David J. Flanagan
''To Obsolete a Method''\n\n{{{\n<Obsolete("Use Bar instead."), _\nComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Never)> _\nPublic Sub Foo()\nEnd Sub\n}}}
''Populate Infragistics UltraComboEditor with an array.''\n\n{{{\nDim routeNumbers() As Integer = {1, 2, 3, 4, 5, 6, 7, 8, 9}\nMe.uiRouteNumberCombo.SetDataBinding(routeNumbers, "")\n}}}
''RSA Key Generation Times using RSACryptoServiceProvider on a Dell Latitude D820 Intel CPU T2500 (Dual Core) @ 2.00GHz.''\n\nTest code:\n{{{\nDim keySize As Integer = 8192 \nDim rsa As RSACryptoServiceProvider = New RSACryptoServiceProvider(keySize) ' Default Keysize is 1024. \n\nDim sw As System.Diagnostics.Stopwatch\nsw = Stopwatch.StartNew\n\nDim publicKey As String = rsa.ToXmlString(False) ' Get the public key.\nDim privateKey As String = rsa.ToXmlString(True) ' Get the private key.\n\nDebug.Print("rsa.KeySize: {0}; publicKey.Length: {1}; privateKey.Length: {2}; {3} msecs", _\n rsa.KeySize, publicKey.Length, privateKey.Length, sw.ElapsedMilliseconds)\n}}}\n\nOutput:\nrsa.KeySize: 1024; publicKey.Length: 243; privateKey.Length: 915; 95 msecs\nrsa.KeySize: 2048; publicKey.Length: 415; privateKey.Length: 1679; 849 msecs\nrsa.KeySize: 4096; publicKey.Length: 755; privateKey.Length: 3219; 5946 msecs (5.9 seconds)\nrsa.KeySize: 8192; publicKey.Length: 1439; privateKey.Length: 6287; 338394 msecs (5 minutes; 37 seconds)\nrsa.KeySize: 12288; publicKey.Length: 2119; privateKey.Length: 9347; 696923 msecs (11 minutes; 36 seconds)
''Registering ASP.NET version 2.0 on IIS''\n{{{\nC:\sWINDOWS\sMicrosoft.NET\sFramework\sv2.0.50727\saspnet_regiis /i\n}}}
''Removing UltraGrid SplitterBar''\n\nIn the form designer.vb file remove code like this:\n{{{\nDim RowScrollRegion1 As Infragistics.Win.UltraWinGrid.RowScrollRegion = New Infragistics.Win.UltraWinGrid.RowScrollRegion(0)\nDim RowScrollRegion2 As Infragistics.Win.UltraWinGrid.RowScrollRegion = New Infragistics.Win.UltraWinGrid.RowScrollRegion(265)\nRowScrollRegion1.ScrollPosition = 0\nRowScrollRegion2.ScrollPosition = 0\nMe.uiUltraGrid.DisplayLayout.RowScrollRegions.Add(RowScrollRegion1)\nMe.uiUltraGrid.DisplayLayout.RowScrollRegions.Add(RowScrollRegion2)\n\n}}}\n
''Disabling the Windows update restart reprompt.''\n\n[[Daniel Turini|http://dturini.blogspot.com/]] has written this tip on [[CodeProject|http://www.codeproject.com/lounge.asp?msg=1254875#xx1254875xx]]:\n<<<\nI found this after a lot of Googling, so I'd like to share the solution. Yep, this may not be new or even advanced but it surely helped me...\n\nAnyone who is running Windows XP SP2 know what I'm talking about. That stupid, annoying, most ill-designed dialog box ever invented in the history of the computer science that asks "Updating your computer is almost complete. You must restart your computer for the updates to take effect. Do you want to restart your computer now?" And there are only two options: Restart Now/Restart Later. "Restart Later" means that this stupid thing will ask you again in 10 minutes. Yes, if you're willing to work for the next 4 hours until lunch before rebooting, this means you'll need to answer this question 24 times. Did I mention that the dialog steals the focus?\n\nNow, to get rid of it:\nStart / Run / gpedit.msc / Local Computer Policy / Computer Configuration / Administrative Templates / Windows Components / Windows Update / Re-prompt for restart with scheduled installations\n\nYou can configure how often it will nag you (I re-configured it for 720 minutes, which means I'll be asked twice on a work day), or completely disable it.\n\nOh, I almost forgot: this setting is only loaded when Windows starts, so a reboot is needed. If that stupid dialog is on your screen now, just stop the "Automatic Updates" service (but keep it as Automatic, so it gets reloaded on the next start) and you won't see it again. \n<<<
''SQL Database Date Time Rounding Problem''\n\nIf the current date and time is saved in a .NET DateTime variable and then that value is store and retrieved from a SQL Server the returned value might not be the same as the original value. The problem is caused by the rounding of milliseconds. One solution is to only store date and time values to the second.\n{{{\nDim nowDateTime As Date = Now\nDim currentDateTime As Date = New Date(nowDateTime.Year, nowDateTime.Month, nowDateTime.Day, nowDateTime.Hour, nowDateTime.Minute, nowDateTime.Second) \n}}}
''Display Columns with varchar(MAX)''\n{{{\nselect \n so.name as TableName, \n sc.name as ColumnName, \n st.name as ColumnType, \n sc.length as ColumnSize\nfrom \n syscolumns sc \ninner join \n sysobjects so \n on \n sc.id = so.id\ninner join\n systypes st\n on\n st.xtype = sc.xtype\nwhere \n so.xtype = 'U' and \n (st.name = 'varchar' or st.name = 'nvarchar') and \n sc.length = -1\norder by \n so.name, \n sc.colid\n}}}\nCreated by Ricke E. Stauffer, Jr.
''Display Columns with Name of Note or Long Length''\n{{{\nselect \n so.name as TableName, \n sc.name as ColumnName, \n st.name as ColumnType, \n sc.length as ColumnSize\nfrom \n syscolumns sc \ninner join \n sysobjects so \n on \n sc.id = so.id\ninner join\n systypes st\n on\n st.xtype = sc.xtype\nwhere \n so.xtype = 'U' and \n (st.name = 'varchar' or st.name = 'nvarchar') and \n (sc.length > 254 or sc.name like '%note%')\norder by \n so.name, \n sc.colid\n}}}\nCreated by Ricke E. Stauffer, Jr.
''List columns in alphabetical order''\n{{{\ndeclare @TableName nvarchar(255)\n-- Change this to set which table\nset @TableName = 'Customer'\n\nSELECT\n sc.name as [ColumnName], \n st.name as [Type], \n sc.length as [Length],\n sc.prec as [Precision],\n sc.scale as [Scale], \n Case\n when sc.isnullable = 0 Then 'False'\n Else 'True'\n End As [IsNullable],\n sc.colorder as [ColumnOrder]\nFROM \n syscolumns sc \nINNER JOIN \n sysobjects so on sc.id = so.id\nINNER JOIN \n systypes st on sc.xtype = st.xtype\nWHERE \n so.name = @TableName\nORDER BY \n sc.name\n}}}\nCreated by Ricke E. Stauffer, Jr.\n
''List row widths for all user tables''\n{{{\n/******************************\n* Return total width of table *\n* *\n* SQL Server max width = 8060 *\n******************************/\n\nSELECT\n so.name as [Table Name], \n sum(sc.length) As [Row Width (bytes)]\nFROM \n syscolumns sc \nINNER JOIN \n sysobjects so on sc.id = so.id\nINNER JOIN \n systypes st on sc.xtype = st.xtype\nWHERE\n so.xtype = 'U'\n/*uncomment this if limiting to the width of one particular\nfield type */\n-- and st.name = 'varchar' \nGROUP BY\n so.name\n}}}\nCreated by Ricke E. Stauffer, Jr.\n
''List table names with specific column name''\n{{{\nselect so.name as tablename, sc.name as columnname from syscolumns sc\ninner join sysobjects so on sc.id = so.id\nwhere so.xtype = 'U' and sc.name = 'LastName'\n}}}\nCreated by Dave J. Flanagan
''Installing SQL Server Sample Databases''\n{{{\n - Northwind and Pub\n - http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46A0-8DA2-EEBC53A68034&displaylang=en\n Northwind and pubs Sample Databases for SQL Server 2000\n - Download SQL2000SampleDb.msi\n - Install creates C:\sSQL Server 2000 Sample Databases\n - SQL Server Management Studio / File / Open / File :\n - C:\sSQL Server 2000 Sample Databases\sinstnwnd.sql and Execute\n - C:\sSQL Server 2000 Sample Databases\sinstpubs.sql and Execute\n - AdventureWorks\n - http://www.microsoft.com/downloads/details.aspx?familyid=E719ECF7-9F46-4312-AF89-6AD8702E4E6E&displaylang=en\n SQL Server 2005 Samples and Sample Databases (April 2006)\n - Download AdventureWorksDB.msi -- 27,992 KB (case-sensitive collation)\n - Installed to C:\sProgram Files\sMicrosoft SQL Server\sMSSQL.1\sMSSQL\sData\s\n - In SQL Server Management Studio\n - Right click on Databases\n - Click Attach Databases\n - Click Add...\n - Select AdventureWorks_Data.mdf\n}}}
''Get SQL Server Version Number''\n\n{{{\nSELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')\n}}}
''Setting an Enum variable via a string.''\n{{{\nPublic Enum ColorThemeType\n Red\n White\n Blue\nEnd Enum\n\n' Set initial color to Blue.\nDim colorTheme As ColorThemeType = ColorThemeType.Blue\n\n' Set color using string "Red".\ncolorTheme = CType([Enum].Parse(GetType(ColorThemeType), "Red"), ColorThemeType)\n}}}
''Simple SQL Select and Update commands.''\n{{{\nSELECT RateType, IsHourly FROM Schedule WHERE (NOT (RateType = 'Flat'))\nUPDATE Schedule SET IsHourly = 'False' WHERE (RateType = 'Flat')\nUPDATE Schedule SET IsHourly = 'True' WHERE (NOT RateType = 'Flat')\n\nSELECT DebitCredit, IsDebit FROM Adjustment WHERE (NOT (DebitCredit = 'Credit'))\nUPDATE Adjustment SET IsDebit = 'False' WHERE (DebitCredit = 'Credit')\nUPDATE Adjustment SET IsDebit = 'True' WHERE (NOT DebitCredit = 'Credit')\n\nUPDATE Customer\n SET Customer.LeadSourceID = lkup.LeadSourceID\n FROM Customer Cust\n INNER JOIN LkupLeadSource Lkup \n ON Cust.LeadSource = Lkup.Description\n}}}\n
all things .NET
Huntware Wiki
''Sorting Controls by Tab Index''\n{{{\nDim controlsByTabIndex As Generic.SortedList(Of Integer, Control) = New Generic.SortedList(Of Integer, Control)\nFor Each cntrl As Control In Me.Controls\n controlsByTabIndex.Add(cntrl.TabIndex, cntrl)\nNext cntrl\n\nFor Each tabIndexAndControl As Generic.KeyValuePair(Of Integer, Control) In controlsByTabIndex\n Dim cntrl As Control = tabIndexAndControl.Value\nNext tabIndexAndControl\n}}}
''Split String to List''\n{{{\nDim routeIDList As List(Of String) = New List(Of String)(routeIDs.Split(","c))\nFor Each routeNode In Me.ScheduleNode\n If routeIDs.Length > 0 Then\n If Not routeIDList.Contains(routeNode.RouteID.ToString) Then\n Continue For\n End If\n End If\nNext routeNode\n}}}
''A simple String Builder example.''\n\n{{{\nDim firstName As String = "John"\nDim initial As String = "A."\nDim lastName As String = "Smith"\n\nDim builder As System.Text.StringBuilder = New System.Text.StringBuilder\nbuilder.Append(lastName)\nbuilder.Append(", ")\nbuilder.Append(firstName)\nbuilder.Append(" "c)\nbuilder.Append(initial)\n\nDim fullName as string = builder.ToString\n}}}
''Team Foundation Commands''\n\nThe tf command is the fundamental command used by Team Foundation Server. Get to it by opening up a Visual Studio Command Prompt\n\nShows what files will get retrieved if you do a get latest:\n{{{\ntf get /preview\n}}}\nDoes a get latest:\n{{{\ntf get\n}}}\nShows all reservations for all users:\n{{{\ntf status /user:*\n}}}\nCompare local file to server:\n{{{\ntf difference BOScheduleItem.vb /format:context\n}}}\nShows the online help:\n{{{\ntf -?\n}}}\nCredit: Bruce Franson
''Timing code with stopwatch.''\n\n\n{{{\nDim sw As System.Diagnostics.Stopwatch\n\nsw = Stopwatch.StartNew\nDoSomeWork()\nDebug.Print("Some Work: {0} msecs", sw.ElapsedMilliseconds)\n\nsw = Stopwatch.StartNew\nDoMoreWork()\nDebug.Print("More Work: {0} msecs", sw.ElapsedMilliseconds)\n}}}
''Setting UltraGrid AutoFit to Extend Last Column''\n\nTo set the UltraGrid Autofit to extend last column to the rest of the form use the UltraWinGrid Designer:\n\n[img[UltraWinGrid Designer Changing Tab Navigation|http://www.huntware.com/UltraGridExtendLastColumn.jpg]]
''Setting UltraGrid Column Header to Invisible''\n\nTo set the UltraGrid Column Header to invisible use the UltraWinGrid Designer:\n\n[img[UltraWinGrid Designer Changing Column Header to Invisible|http://www.huntware.com/UltraGridColHeadersVisible.jpg]]
''Setting UltraGrid Tab Navigation to NextControlOnLastCell''\n\nTo set the UltraGrid to tab off of the last row and on to the next control in the tab order using the following code:\n{{{\nMe.uiGrdScheduleTime.DisplayLayout.TabNavigation = _ \n Infragistics.Win.UltraWinGrid.TabNavigation.NextControlOnLastCell\n}}}\n\nOr use the UltraWinGrid Designer:\n\n[img[UltraWinGrid Designer Changing Tab Navigation|http://www.huntware.com/UltraGridNextControlOnLastCell.jpg]]
''Setting UltraWinCombo LimitToList''\n\nTo set the UltraWinCombo LimitToList use the UltraWinCombo Designer:\n\n[img[UltraWinCombo Designer Changing LimitToList|http://www.huntware.com/UltraWinComboLimitToList.jpg]]
''Setting UltraWinCombo MaxDropDownItems''\n\nTo set the UltraWinCombo MaxDropDownItemsuse the UltraWinCombo Designer:\n\n[img[UltraWinCombo Designer Changing MaxDropDownItems|http://www.huntware.com/UltraWinComboMaxDropDownItems.jpg]]
Saving VS2005 Window Layouts\n{{{\nTools / Import and Export Settings ...\n\nOn: "Export selected environment settings"\nNext>\n\nOff: "All Settings"\nDrill down to "All Settings" / "General Settings" / "Window Layouts"\nOn: "Window Layouts"\nNext>\n\nFilename: TwoMonitorsWindowLayout.vssettings\nFinish\nClose\n}}}\n\nRestoring VS2005 Window Layouts\n{{{\nTools / Import and Export Settings ...\n\nOn: "Import selected environment settings"\nNext>\n\nOn: "Yes, save my current settings" (okay to use default filename)\nNext>\n\nSelect My Setting: TwoMonitorsWindowLayout.vssettings\nFinish\nClose\n}}}
''VS 2005: Setting Debug Break On Exception''\n\nTo bring up the Visual Studio 2005 Debug Exception window type Ctrl-Alt-E.\n\n[img[Debug Break On Exception Default|http://www.huntware.com/VS2005DebugBreakOnExceptionDefault.jpg]]\n\nThe following will cause the debugger to break even in a Try/Catch block.\n\n[img[Debug Break On Exception Set|http://www.huntware.com/VS2005DebugBreakOnExceptionSet.jpg]]
''Webcasts Recommended for SSI Tech Lunch''\n\nTitle: dnrTV Show #9 | 3/9/2006 | Venkat is Back with Generics!\nDescription: Venkat Subramaniam is back to talk about Generics. This may be the first Generics demo you've seen that does not use collections (we're proud of that). Of course, Venkat brings his inquisitive style to the topic. You're sure to enjoy it!\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0009.zip}}}\nComment: Excellent but examples are C#.\n\nTitle: dnrTV Show #40 | 10/19/2006 | Mark Miller on Events and Delegates\nDescription: Mark Miller takes delegates, a fundamental programming feature, where few have gone before. This show is as entertaining as it is educational.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0040.zip}}}\nComment: Very good and interesting. Demo in C#.\n\nTitle: dnrTV Show #65 | 5/4/2007 | Jean-Paul Boodhoo on Demystifying Design Patterns Part 2\nDescription: This week Jean-Paul Boodhoo continues his design pattern series. Jean-Paul shows us two more patterns, Monostate and Strategy.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0065.zip}}}\nComment: Excellent C# code examples. Besides reviewing design patterns show the value of using interfaces.\n\nTitle: dnrTV Show #56 | 3/2/2007 | Brian Noyes on Windows Presentation Foundation Part 1\nDescription: Virginia RD Brian Noyes is back to formally introduce us to Windows Presentation Foundation, the whiz bang GUI portion of .NET 3.0. Brian gives us some dazzling real world examples of WPF in action and then goes into the object/element hierarchy with data binding.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0056.zip}}}\nComment: Excellent demo on Windows Presentation Foundation. Unfortunately, the beta version of WPF still doesn't have a well developed Form Designer so the demos uses the code-behind XML to edit the form.\n\nTitle: dnrTV Show #59 | 3/23/2007 | Brian Noyes on Windows Presentation Foundation Part 2\nDescription: Mr. Brian Noyes is back with another episode on MS WPF. This time Brian gets into the Expression Blend design tool, styles, triggers and a XAML browser application.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0059.zip}}}\nComment: Excellent demo on Windows Presentation Foundation. Unfortunately, the beta version of WPF still doesn't have a well developed Form Designer so the demos uses the code-behind XML to edit the form.\n\nTitle: dnrTV Show #82 | 9/7/2007 | Scott Hanselman on Windows PowerShell\nDescription: The Hanselmaster is back on dnrTV with a great command shell tool that should have come with Windows: PowerShell. Add an additional free extension library and you'll be amazed at the powerful scripts you'll be able to write.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0082.zip}}}\nComment: A very nice introduction to PowerShell.
''Webcasts Viewed at SSI Tech Lunch''\n\nTitle: Show #3 | 1/26/2006 | Venkat Subramaniam on .NET Gotchas\nDescription: Venkat Subramaniam, author of .NET Gotchas, shows 5 different issues with .NET, and how to work around them.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0003.zip}}}\nComment: Very good but many examples in C#.\n\nTitle: Show #4 | 2/1/2006 | Venkat Subramaniam on Multithreading Gotchas\nDescription: Venkat Subramaniam, author of .NET Gotchas, is back to begin a discussion of multithreading gotchas. If you're new to threading, this will be a challenging introduction.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0004.zip}}}\nComment: Very good but many examples in C#.\n\nTitle: dnrTV Show #35 | 9/10/2006 | Scott Hanselman on Sysinternals Tools\nDescription: Our good friend Scott Hanselman pays us a visit to show us the nitty gritty of some of his favorite Sysinternals tools.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0035.zip}}}\nComment: Excellent review of PC tools by Sysinternals.\n\nTitle: dnrTV Show #39 | 10/5/2006 | Juval Lowy on .NET 3.0 Part 1\nDescription: Juval Lowy introduces us to .NET 3.0, clearing up misconceptions and showing off the power of Windows Communication Foundation with a few choice demos.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0039.zip}}}\nComment: PowerPoint slides until 48:30 minutes. Best to view just the code demos from 48:30 to 54:00 and 59:30 to 1:04:00 and then view Show #42 for the rest of the great code demos. Code demos are in C#.\n\nTitle: dnrTV Show #42 | 11/2/2006 | Juval Lowy on .NET 3.0 Part 2\nDescription: Juval is back to show us more mind blowing demos of Windows Communication Foundation in .NET 3.0.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0042.zip}}}\nComment: Awesome code demos in #C.\n\nTitle: dnrTV Show #44 | 11/17/2006 | Mark Miller on Load on Demand\nDescription: Mark is back to show us how to cut down your gui intensive application load time to about a half a second by only loading assemblies as you require them.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0044.zip}}}\nComment: Excellent and interesting. Demo in C#.\n\nTitle: dnrTV Show #49 | 1/11/2007\nJoe Stagner on ASP.NET AJAX Part 1 of 2\nMr. Joe Stagner visits New London to give us the scoop on the new ASP.NET AJAX. In this first show, Joe shows us all the plumbing from the 10,000 ft view right down to the elbow pipe.\nComment: Excellent. Great simple example of AJAX to a webservice.\n\nTitle: dnrTV Show #50 | 1/18/2007\nJoe Stagner on ASP.NET AJAX Part 2 of 2\nJoe is back to show us more of ASP.NET AJAX including user defined types, scripting model extension demos and the Microsoft AJAX Control Toolkit.\nComment: Excellent. Great simple example of AJAX to a webservice.\n\nTitle: dnrTV Show #63 | 4/20/2007 | Jean-Paul Boodhoo on Demystifying Design Patterns Part 1\nDescription: Jean-Paul Boodhoo starts a multi part series on design patterns that can be applied in any environment. This week Jean-Paul explores Factories and Singletons in ways you may not have thought of.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0063.zip}}}\nComment: Excellent C# code examples. Besides reviewing design patterns show the value of using interfaces.\n\nTitle: dnrTV Show #66 | 5/11/2007 | Scott Hanselman on Debugging in .NET 2005\nDescription: Scott Hanselman is back on dnrTV! This time Scott shares his extensive knowledge of the .NET environment to show you how to see exactly what your code is doing and how it's doing it.\nLocation: {{{\s\sSSIServer01\sswdata\sArchive\sdnrTV\sdnrTV_0066.zip}}}\nComment: Very good, especially helpful for the ASP.NET environment. Shows the difference between debug and trace messages. Uses SysInternals TcpView and SysInternals DebugView.\n\nTitle: dnrTV Show #78 | 8/10/2007\nScott Hanselman on Debugging Part 2\nMr. Hanselman returns with Part 2 of his debugging in .NET 2005 series. This time\nScott explains evaluating processes in the Process Explorer from Sysinternals. Also..\nwhat are these symbols all about anyway?\nComment: Excellent.\n\nTitle: dnrTV Show #97 | 12/21/2007\nKathleen Dollard on Comparing C# and VB in .NET 3.5\nKathleen Dollard brings her expertise to the dnrTV screen this week. In this first of a two part series, Kathleen gives us a broad overview of how we got to where we are today. Also, she gives us an in-depth comparison/contrast of the new .NET 3.5 features in C# and VB.\nComment: Excellent.\n\nTitle: dnrTV Show #98 | 1/4/2008\nKathleen Dollard on Comparing C# and VB in .NET 3.5 Part 2\nKathleen Dollard returns to dnrTV this week to wrap up her two part series on special features in .NET 3.5. This time Kathleen shows us lambda expressions, anonymous methods and Linq.\nComment: Excellent.\n\nTitle: dnrTV Show #103 | 2/8/2008\nMiguel Castro and Mark Dunn on the Marriage of WF and WCF\nThis week Miguel Castro and Mark Dunn join Carl live on stage at the Raleigh Code Camp to show how to marry Workflow and Windows Communication Foundation. These elusive features seem like they should be a no-brainer, but it took Miguel and Mark at least one long night and a few beers to figure it all out so you don't have to.\nComment: Excellent\n
''Converting XML To String; different methods produces different formats.''\n\n''Setup code''\n{{{\nDim doc As New System.Xml.XmlDocument\nDim node1 As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, "DataIdentifier", "")\n\nDim node2 As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, "Table", "")\nnode2.InnerText = "Customer"\n\nDim node3 As System.Xml.XmlNode = doc.CreateNode(XmlNodeType.Element, "CustomerID", "")\nnode3.InnerText = "1000"\n\nnode1.AppendChild(node2)\nnode1.AppendChild(node3)\n\ndoc.AppendChild(node1)\n}}}\n''First method''\n{{{\nDim sw As System.IO.StringWriter = New System.IO.StringWriter()\nDim xw As XmlTextWriter = New XmlTextWriter(sw)\ndoc.WriteTo(xw)\nDim xmlString As String = sw.ToString()\n\nValue of xmlString:\n"<DataIdentifier><Table>Customer</Table><CustomerID>1000</CustomerID></DataIdentifier>"\n}}}\n''Second method''\n{{{\nDim sw As System.IO.StringWriter = New System.IO.StringWriter\ndoc.Save(sw)\nDim xmlString As String = sw.ToString\n\nValue of xmlString:\n"<?xml version="1.0" encoding="utf-16"?>\n<DataIdentifier>\n <Table>Customer</Table>\n <CustomerID>1000</CustomerID>\n</DataIdentifier>"\n}}}\n''Third method''\n{{{\nDim memStream As System.IO.MemoryStream = New System.IO.MemoryStream()\ndoc.Save(memStream)\nDim xmlString As String = System.Text.Encoding.UTF8.GetString(memStream.GetBuffer(), 0, memStream.GetBuffer().Length)\n\nValue of xmlString:\n"<DataIdentifier>\n <Table>Customer</Table>\n <CustomerID>1000</CustomerID>\n</DataIdentifier>"\n\nNote; this method appears to produce an unreadable character at the end of the string.\n}}}\n''Fourth method''\n{{{\nDim memStream As System.IO.MemoryStream = New System.IO.MemoryStream()\ndoc.Save(memStream)\nmemStream.Seek(0, 0)\nDim reader As System.IO.StreamReader = New System.IO.StreamReader(memStream, System.Text.Encoding.UTF8)\nDim xmlString As String = reader.ReadToEnd()\n\nValue of xmlString:\n"<DataIdentifier>\n <Table>Customer</Table>\n <CustomerID>1000</CustomerID>\n</DataIdentifier>"\n}}}