SQL Server Merge Replication#

One of the challenges in doing merge replication in SQL Server is dealing with IDENTITY columns.

One of the tricks you can use is "automatic identity range management". 

Basically you tell DB 1 to start at seed 1 and DB 2 to seed at 20,000, and when DB 1 reaches 16,000 or DB 2 reaches 36,000 it will reset those seeds to 40,000 and 60,000.

http://msdn2.microsoft.com/en-us/library/ms152543.aspx

http://msdn2.microsoft.com/en-us/library/ms146907.aspx

It appears to work well.

Categories: Programming | Database | SQL Server
Tuesday, August 29, 2006 2:55:35 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Getting IE To Print Backgrounds And Cell Colors#

I was having a small problem getting some reports to print the way I wanted.

I turns out that to get the table cells colored backgrounds to print, click on the browser’s Tools menu. Select Internet Options, then click on the Advanced tab. Scroll down to find the Printing heading and check the box called Print Background Colors and Images. This setting affects both page backgrounds and table cell backgrounds.

Categories: Programming | HTML
Saturday, August 26, 2006 6:57:53 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Using XSD.exe#

.Net has a tool called the XML Schema Definition Tool (XSD.EXE) which can turn XSD schemas into classes.  Also, it will try to make it so those classes will conform to the schema when serialized as XML.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconxmlschemadefinitiontoolxsdexe.asp

xsd.exe pathToXSD.xsd /classes /language:VB /outputdir:C:\output

You can then serialize and deserialize the object into/from XML.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassTopic.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlSerializationXmlSerializerClassDeserializeTopic.asp

 

 

Categories: Programming | .Net | XML
Friday, August 25, 2006 3:10:35 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Is The Date On The Weekend#

This function will figure out if the given date lands on a weekend.

    Public Shared Function IsWeekend(ByVal dateOfInterest As DateTime) As Boolean
Dim d, m, y, w As Integer
d = dateOfInterest.Day
m = dateOfInterest.Month
y = dateOfInterest.Year


If m = 1 Or m = 2 Then
m += 12
y -= 1
End If


w = CInt((d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) Mod 7)
If w <> 6 And w <> 7 Then
Return False
Else
Return True
End If
End Function

Another function to do the weekend check could be this:

    Private Const ERR_INVALID_DATE = 20000
Private Const ERR_INVALID_DATE_MSG = "Date Required"

Public Function IsWeekend(ByVal DateValue As Object) As Boolean

Dim dDateValue As Date

If Not IsDate(DateValue) Then
Err.Raise(ERR_INVALID_DATE, ERR_INVALID_DATE_MSG)
Exit Function
End If

dDateValue = CDate(DateValue)
IsWeekend = (Weekday(dDateValue) Mod 6 = 1)

End Function
Categories: Programming | .Net
Friday, August 25, 2006 12:33:23 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Using Postbacks in ASP.NET From showModalDialog pages.#

If you have an ASP.NET page (.aspx) opened with the JavaScript showModalDialog() function and inside that page there is a form doing PostBack, when the PostBack is being done the page loads in another (popup) window. The easiest way to prevent this is to add the following tag inside the <HEAD></HEAD> tags of the ASP.NET page:

<base target="_self">

From: http://www.geekpedia.com/Question23_Using-showModalDialog()-with-an-ASP.NET-page-that-does-PostBack-opens-another-window.html

Categories: Programming | .Net | ASP.Net
Thursday, August 24, 2006 2:52:59 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

Databinding "Bind()" in ASP.NET#

If you used the developemt tools to create a datagrid in ASP.NET 2.0, it will show something like:

NavigateUrl='<%# Bind("EmployeeId") %>'

But what if you wanted to do something more complicated that just ge the EmployeeId into the field, like for example if you wanted to run a JS function.  Then you have to do away with Bind and use the more verbose DataBinder method like this: 

NavigateUrl='<%# "javascript:UseThisJobIndex(" & DataBinder.Eval(Container.DataItem,"JobIndex") & ")" %>'

That's all there is to it.

 

Categories: Programming | .Net | ASP.Net | DataBinding
Thursday, August 24, 2006 1:16:56 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

My Very Educated Mother Just Said Uh-oh No Pluto!!#
http://msnbc.msn.com/id/14489259/

I wish I coudl take credit for that line, but it was from Colbert.

So now Pluto is going to be a Drawf Planet, along with UB313 (Xena) and Ceres.


To see the full image you might need to expand your window or use the scrollbar at the bottom of this article.

UB313 is larger than Pluto, and farther out in orbit.

I kinda liked the idea of calling Pluto and Charon a "dual planet," as Charon is so large that it was somewhat unfair to say that it orbits Pluto, but they aren't going to do that.

Ceres is the largest asteroid in the Asteroid Belt but because it hasn't swept the area clear of other asteroids (and I guess it never will b/c of its close proximity to Jupiter) it will never meet the new definition of a planet:

“a celestial body that is in orbit around the sun, has sufficient mass for its self-gravity to overcome rigid body forces so that it assumes a nearly round shape, and has cleared the neighborhood around its orbit.”

Categories: Cool | Science
Thursday, August 24, 2006 11:20:08 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Backup/Restore Cisco Pix Configuration#

To do this you

  1. Need a TFTP server running (solarwinds)
  2. Need to telnet into the device
  3. Need to be in enable mode

First to make the backup:

write net 192.168.1.2:MyBackup.pixconfig

where the IP is the IP of your TFTPserver

Then to restore it later, you need to enter config terminal mode first and then restore the file:

config term
configure net 192.168.1.2:MyBackup.pixconfig

and there you have it...

The changes will take immediate effect, but you will still need to write them into the non volatile memory, or the changes will be lost when you reboot the device.

 

Categories: Networking | Firewall | Security
Friday, August 11, 2006 4:55:29 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Fountain of Time#
Categories: Cool
Friday, August 11, 2006 10:55:47 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Throwing the Right Exception#

Brad Abrams has a good article out there showing a list of all the .net exceptions you can throw from your code.

There are some exceptions that are not shown here, for example ConfigurationException, but this is a good starting point.

From Brad's article:

+--System.Object  

   |

   |

   +--System.Exception  

       |

       |

       +--System.SystemException  

           |

           |

           +--System.ArgumentException  

           |   |

           |   |

           |   +--System.ArgumentNullException  

           |   |

           |   |

           |   +--System.ArgumentOutOfRangeException  

           |   |

           |   |

           |   +--System.DuplicateWaitObjectException  

           |

           |

           +--System.ArithmeticException  

           |   |

           |   |

           |   +--System.DivideByZeroException  

           |   |

           |   |

           |   +--System.OverflowException  

           |   |

           |   |

           |   +--System.NotFiniteNumberException

           |

           |

           +--System.ArrayTypeMismatchException  

           |

           |

           +--System.ExecutionEngineException  

           |

           |

           +--System.FormatException  

           |

           |

           +--System.IndexOutOfRangeException  

           |

           |

           +--System.InvalidCastException  

           |

           |

           +--System.InvalidOperationException  

           |   |

           |   |

           |   +--System.ObjectDisposedException  

           |

           |

           +--System.InvalidProgramException  

           |

           |

           +--System.IO.IOException  

           |   |

           |   |

           |   +--System.IO.DirectoryNotFoundException  

           |   |

           |   |

           |   +--System.IO.EndOfStreamException  

           |   |

           |   |

           |   +--System.IO.FileLoadException  

           |   |

           |   |

           |   +--System.IO.FileNotFoundException  

           |   |

           |   |

           |   +--System.IO.PathTooLongException  

           |

           |

           +--System.NotImplementedException  

           |

           |

           +--System.NotSupportedException  

           |

           |

           +--System.NullReferenceException  

           |

           |

           +--System.OutOfMemoryException  

           |

           |

           +--System.RankException  

           |

           |

           +--System.Security.SecurityException  

           |

           |

           +--System.Security.VerificationException  

           |

           |

           +--System.StackOverflowException  

           |

           |

           +--System.Threading.SynchronizationLockException  

           |

           |

           +--System.Threading.ThreadAbortException  

           |

           |

           +--System.Threading.ThreadStateException  

           |

           |

           +--System.TypeInitializationException  

           |

           |

           +--System.UnauthorizedAccessException 


Jeff Atwood put up another article where he uses a little console app to find all classes named "*Exception". 


Here is his list:


System.AppDomainUnloadedException
System.ApplicationException
System.ArgumentException
System.ArgumentNullException
System.ArgumentOutOfRangeException
System.ArithmeticException
System.ArrayTypeMismatchException
System.BadImageFormatException
System.CannotUnloadAppDomainException
System.ComponentModel.Design.CheckoutException
System.ComponentModel.Design.Serialization.CodeDomSerializerException
System.ComponentModel.InvalidEnumArgumentException
System.ComponentModel.LicenseException
System.ComponentModel.WarningException
System.ComponentModel.Win32Exception
System.Configuration.ConfigurationException
System.ContextMarshalException
System.Data.ConstraintException
System.Data.DataException
System.Data.DBConcurrencyException
System.Data.DeletedRowInaccessibleException
System.Data.DuplicateNameException
System.Data.EvaluateException
System.Data.ExprException
System.Data.InRowChangingEventException
System.Data.InvalidConstraintException
System.Data.InvalidExpressionException
System.Data.MissingPrimaryKeyException
System.Data.NoNullAllowedException
System.Data.Odbc.OdbcException
System.Data.OleDb.OleDbException
System.Data.ReadOnlyException
System.Data.RowNotInTableException
System.Data.SqlClient._ValueException
System.Data.SqlClient.SqlException
System.Data.SqlTypes.SqlNullValueException
System.Data.SqlTypes.SqlTruncateException
System.Data.SqlTypes.SqlTypeException
System.Data.StrongTypingException
System.Data.SyntaxErrorException
System.Data.TypedDataSetGeneratorException
System.Data.VersionNotFoundException
System.DivideByZeroException
System.DllNotFoundException
System.Drawing.Printing.InvalidPrinterException
System.DuplicateWaitObjectException
System.EntryPointNotFoundException
System.Exception
System.ExecutionEngineException
System.FieldAccessException
System.FormatException
System.IndexOutOfRangeException
System.InvalidCastException
System.InvalidOperationException
System.InvalidProgramException
System.IO.DirectoryNotFoundException
System.IO.EndOfStreamException
System.IO.FileLoadException
System.IO.FileNotFoundException
System.IO.InternalBufferOverflowException
System.IO.IOException
System.IO.IsolatedStorage.IsolatedStorageException
System.IO.PathTooLongException
System.Management.ManagementException
System.MemberAccessException
System.Messaging.MessageQueueException
System.MethodAccessException
System.MissingFieldException
System.MissingMemberException
System.MissingMethodException
System.MulticastNotSupportedException
System.Net.CookieException
System.Net.ProtocolViolationException
System.Net.Sockets.SocketException
System.Net.WebException
System.NotFiniteNumberException
System.NotImplementedException
System.NotSupportedException
System.NullReferenceException
System.ObjectDisposedException
System.OutOfMemoryException
System.OverflowException
System.PlatformNotSupportedException
System.RankException
System.Reflection.AmbiguousMatchException
System.Reflection.CustomAttributeFormatException
System.Reflection.InvalidFilterCriteriaException
System.Reflection.ReflectionTypeLoadException
System.Reflection.TargetException
System.Reflection.TargetInvocationException
System.Reflection.TargetParameterCountException
System.Resources.MissingManifestResourceException
System.Runtime.InteropServices.COMException
System.Runtime.InteropServices.ExternalException
System.Runtime.InteropServices.InvalidComObjectException
System.Runtime.InteropServices.InvalidOleVariantTypeException
System.Runtime.InteropServices.MarshalDirectiveException
System.Runtime.InteropServices.SafeArrayRankMismatchException
System.Runtime.InteropServices.SafeArrayTypeMismatchException
System.Runtime.InteropServices.SEHException
System.Runtime.Remoting.MetadataServices.SUDSGeneratorException
System.Runtime.Remoting.MetadataServices.SUDSParserException
System.Runtime.Remoting.RemotingException
System.Runtime.Remoting.RemotingTimeoutException
System.Runtime.Remoting.ServerException
System.Runtime.Serialization.SerializationException
System.Security.Cryptography.CryptographicException
System.Security.Cryptography.CryptographicUnexpectedOperationException
System.Security.Policy.PolicyException
System.Security.SecurityException
System.Security.VerificationException
System.Security.XmlSyntaxException
System.ServiceProcess.TimeoutException
System.StackOverflowException
System.SystemException
System.Threading.SynchronizationLockException
System.Threading.ThreadAbortException
System.Threading.ThreadInterruptedException
System.Threading.ThreadStateException
System.Threading.ThreadStopException
System.TypeInitializationException
System.TypeLoadException
System.TypeUnloadedException
System.UnauthorizedAccessException
System.UriFormatException
System.Web.HttpApplication+CancelModuleException
System.Web.HttpCompileException
System.Web.HttpException
System.Web.HttpParseException
System.Web.HttpRequestValidationException
System.Web.HttpUnhandledException
System.Web.Services.Discovery.InvalidContentTypeException
System.Web.Services.Discovery.InvalidDocumentContentsException
System.Web.Services.Protocols.SoapException
System.Web.Services.Protocols.SoapHeaderException
System.Windows.Forms.AxHost+InvalidActiveXStateException
System.Xml.Schema.XmlSchemaException
System.Xml.XmlException
System.Xml.XPath.XPathException
System.Xml.Xsl.XsltCompileException


The code used to create this list (.net 1.1) is:


Sub Main()
ReflectionSearch(".*exception$")
Console.ReadLine()
End Sub

Sub ReflectionSearch(ByVal strPattern As String)
Dim a As Reflection.Assembly
Dim m As Reflection.Module
Dim t As Type
Dim al As New ArrayList
Dim sl As New SortedList
Dim strAssemblyName As String

For Each strAssemblyName In DefaultAssemblyList()
a = Reflection.Assembly.Load(strAssemblyName)
For Each m In a.GetModules
For Each t In m.GetTypes
al.Add(t)
Dim strFullName As String = t.FullName
If Regex.IsMatch(strFullName, strPattern, RegexOptions.IgnoreCase) Then
sl.Add(strFullName, Nothing)
End If
Next
Next
Next

Dim de As DictionaryEntry
For Each de In sl
Console.WriteLine(de.Key)
Next
Console.WriteLine(sl.Count.ToString & " matches for " & strPattern)
End Sub

Function DefaultAssemblyList() as ArrayList
Dim al As New ArrayList
With al
.Add("mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
.Add("System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
.Add("System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
.Add("System.Runtime.Remoting, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
.Add("System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
.Add("System.Xml, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
.Add("System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.DirectoryServices, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.Drawing.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.Messaging, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.Runtime.Serialization.Formatters.Soap, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.Security, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.ServiceProcess, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.Web.Services, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.Add("System.Management, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
End With
Return al
End Function

System.Xml.Xsl.XsltException


Categories: Programming | .Net | .Net Framework | Architecture
Thursday, August 10, 2006 11:07:53 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Accessing DLLs stored in the GAC#

You can access the dlls by going to this undocumented folder:

C:\WINDOWS\ASSEMBLY\GAC_MSIL

If you go to C:\WINDOWS\ASSEMBLY\ it will not show you the GAC_MSIL folder, but rather a view of all DLLs that you can't copy.

 

Categories: Programming | .Net | .Net Framework
Wednesday, August 09, 2006 11:35:34 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

VS.Net Macro for Generating Simple and CSLA Property Accessors#

Here are a few macros I wrote to generate property accessors from your class level variables.

These Macros are absolutely not an example of great coding.  They are really pretty crappy, but they do the job, so as I kept tweaking them I never went back to clean up the code or look into more elegant ways to accomplish this stuff.

Some notes about these macros:

1) dasBlog's code display tools somehow screws up the LFs, so if you cut and paste this code you might want to first paste it into Word, or WordPad.

2) These macros need some space between your last bit of code and the end of your class.  In other words, the line directly above "End Class" can't have code in it.  Fixing this bug wouldn't be a big deal but I haven't done it yet.

3) These macros will allow formatting of your variables/accessors in any of the following ways:

private csClassLevelString as String '*** property name "ClassLevelString"
private mModuleLevelInt as Integer '*** property name "ModuleLevelInt"
private _SomeObject as Object '*** property name "SomeObject"
private camelCaseBoolean as Boolean '*** WON'T work: property will be named "CaseBoolean"

4) To use these macros, simply declare your class level (instance) variables.  Then with your mouse, highlight the ones you want to create property accessors for.  You need to highlight the entire definition from "private" to data type, and of course you can highlight a bunch at 1 time.  i.e. I could highlight the entire code block above and it would produce 4 property accessors.

5) Again... this code... well it kinda sucks.  So if you are looking for a lesson on producing good code, avert your eyes, but the output is good.

 

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module Module1

    Public Sub AddClassProperties()
        Call AddClassProperties(False)
    End Sub
    Public Sub AddCslaProperties()
        Call AddClassProperties(True)
    End Sub

    ' highlight the private properties
    Private Sub AddClassProperties(ByVal useCsla As Boolean)

        Dim oTextSelection As TextSelection = DTE.ActiveWindow.Selection
        Dim iLinesSelected = oTextSelection.TextRanges.Count
        Dim colPropertyList As New Collection()
        Dim iIndex As Integer
        Dim oStart As EditPoint = oTextSelection.TopPoint.CreateEditPoint()
        Dim oEnd As TextPoint = oTextSelection.BottomPoint

        'Create an Undo context object so all the changes can be
        'undone by CTRL+Z
        Dim oUnDo As UndoContext = DTE.UndoContext

        'Supress the User Interface. This will make it run faster
        'and make all the changes appear once
        DTE.SuppressUI = True

        Try

            oUnDo.Open("Comment Line")

            Dim sProperty As String
            Dim sLineOfText As String

            Do While (oStart.LessThan(oEnd))

                sLineOfText = oStart.GetText(oStart.LineLength).Trim
                '*** do some kind of simple check to make sure that this line
                '*** isn't blank and isn't some other kind of code or comment
                If (sLineOfText.IndexOf(" As ") >= 0 And ( _
                    (sLineOfText.IndexOf("Public ") >= 0) Or _
                    (sLineOfText.IndexOf("Private ") >= 0) Or _
                    (sLineOfText.IndexOf("Dim ") >= 0) Or _
                    (sLineOfText.IndexOf("Protected ") >= 0) Or _
                    (sLineOfText.IndexOf("Friend ") >= 0) Or _
                    (sLineOfText.IndexOf("ReDim ") >= 0) Or _
                    (sLineOfText.IndexOf("Shared ") >= 0) Or _
                    (sLineOfText.IndexOf("Static ") >= 0) _
                    )) Then

                    sProperty = oStart.GetText(oStart.LineLength).Trim.Replace(" New ", " ").Replace("()", "")

                    colPropertyList.Add(sProperty)
                End If

                oStart.LineDown()
                oStart.StartOfLine()

            Loop

            If colPropertyList.Count > 0 Then

                For Each sProperty In colPropertyList
                    Call InsertProperty(sProperty, useCsla)
                Next

            Else
                MsgBox("You must select the class properties")
            End If

        Catch ex As System.Exception

            Debug.WriteLine(ex)
            If MsgBoxResult.Yes = MsgBox("Error: " & ex.ToString & vbCrLf & "Undo Changes?", MsgBoxStyle.YesNo) Then
                oUnDo.SetAborted()
            End If

            Return
        Finally

            'If an error occured, then need to make sure that the undo context is cleaned up.
            'Otherwise, the editor can be left in a perpetual undo context
            If oUnDo.IsOpen Then
                oUnDo.Close()
            End If

            DTE.SuppressUI = False
        End Try


    End Sub

    Private Sub InsertProperty(ByVal sProp As String, Optional ByVal UseCsla As Boolean = False)
        Dim oTextSelection As TextSelection = DTE.ActiveWindow.Selection
        Dim sMember As String = sProp.Substring(sProp.IndexOf(" ")).Trim
        Dim sDataType As String
        Dim sName As String
        Dim i As Integer
        Dim iAscVal As Integer

        i = sMember.IndexOf("(")
        If Not i = -1 Then
            sMember = sMember.Substring(0, i)
        End If

        i = sMember.IndexOf("=")
        If Not i = -1 Then
            sMember = sMember.Substring(0, i)
        End If

        sDataType = sMember.Substring(sMember.IndexOf(" As ") + 1)

        For i = 0 To sMember.Length - 1
            'iAscVal = Asc(Mid(sName, i, 1))
            iAscVal = Asc(sMember.Chars(i))
            If iAscVal > 64 And iAscVal < 91 Then
                sName = sMember.Substring(i)
                Exit For
            End If
        Next i

        sName = sName.Substring(0, sName.IndexOf(" As ") + 1).Trim

        If sName.Length = 0 Then
            MsgBox("Unable to process the class property: " & sMember & ".  This is usually caused by an incorrect naming convention (e.g. not cxName)")
            Return
        End If

        sMember = sMember.Substring(0, sMember.Length - sDataType.Length).Trim

        With oTextSelection
            Dim pt As TextPoint = .ActivePoint.CodeElement(vsCMElement.vsCMElementClass).GetEndPoint(vsCMPart.vsCMPartWhole)
            If pt Is Nothing Then
                pt = .ActivePoint.CodeElement(vsCMElement.vsCMElementStruct).GetEndPoint(vsCMPart.vsCMPartWhole)
            End If
            .MoveToPoint(pt)
            .LineUp()
            .EndOfLine()

            .Text = "Public Property " & sName & "() " & sDataType
            .NewLine()
            If UseCsla Then
                .Text = "CanReadProperty(True)"
                .NewLine()
            End If
            .Text = "Return " & sMember
            .StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
            .StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn, True)
            .Copy()
            .LineDown(False, 3)
            DTE.ExecuteCommand("Edit.Paste")
            If UseCsla Then
                .Text = "CanWriteProperty(True)"
                .NewLine()
                .Text = "If Me." & sMember & " <> Value then"
                .NewLine()
            End If
            .Text = "Me." & sMember & " = Value"
            If UseCsla Then
                .NewLine()
                .Text = "PropertyHasChanged()"
            End If
            .LineDown(False, 2)
            If UseCsla Then
                .LineDown(False, 1)

            End If
            .NewLine(2)

        End With

    End Sub


End Module

 

 

Categories: Code | Programming | .Net | VB.Net
Thursday, August 03, 2006 7:51:08 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Select DataSource and Visual Studio Errors#

I recently ran into a nebulous problem when creating a windows app with vs.net 2005.

I would select the DataBindings or DataSource properties from the proeprties window (click the dropdown) and VS would give me an "Object reference not set to an instance of an object" error.

Fantastic!

I finally figured out the problem was caused by a recent rename of a misspelled class.

This class was being used by one of the datasources.  As soon as I changed the name of that class, the datasource became invalid, and I guess when VS tries to get a list of the these datasources for the dropdown it just blows up.

Once I deleted the problematic datasource everything went back to normal.

Categories: Programming | .Net | VS.Net | WinForms
Tuesday, August 01, 2006 9:25:40 PM (Central Daylight Time, UTC-05:00) #    Comments [2]  | 

 

Expresso Regular Expression Tool#

Expresso is a free tool that you can download and run to aid you in building and testing regular expressions.

It's pretty handy!

Categories: Programming | .Net | .Net Framework | Utilities
Monday, July 31, 2006 10:19:54 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Validating XML document against an XML Schema with VB.Net#

It seems like validating an XML document against a schema would be a pretty simple thing to do in the .Net framework, seeing as how they have such deep support for dealing with XML.

But as of yet, I haven't found a simple way to do it.

Here is the code I have been using to validate XML against an XML Schema.

Imports System.IO
Imports System.Xml
Imports System.Xml.Schema


Private schemaValidation As New ValidationEventHandler(AddressOf ValidationHandler)

Private Function ValidateXml(ByVal xmlFileName As String, ByVal xmlSchemaName As String) As Boolean
Using myFile As New FileStream(xmlFileName, FileMode.Open, FileAccess.Read, FileShare.None)
Dim xDoc As New Xml.XmlDocument()
xDoc.Load(myFile)
xDoc.Schemas.Add(GetSchema(xmlSchemaName))
Try
xDoc.Validate(schemaValidation)
Return True
Catch ex As XmlSchemaValidationException
Console.Write(ex.ToString)
Return False
Catch ex As XmlSchemaException
Console.Write(ex.ToString)
Return False
Catch ex As Exception
Console.Write(ex.ToString)
Return False
End Try
End Using
End Function

Private Function GetSchema(ByVal filePath As String) As XmlSchema
Dim schema As XmlSchema
Using s As New System.IO.FileStream(filePath, FileMode.Open)
Using reader As New StreamReader(s)
schema = XmlSchema.Read(reader, Nothing)
End Using
End Using
Return schema
End Function

Private Sub ValidationHandler(ByVal sender As Object, ByVal e As System.Xml.Schema.ValidationEventArgs)
Throw e.Exception
End Sub
 
Categories: Programming | .Net | .Net Framework | VB.Net | XML
Saturday, July 29, 2006 4:35:25 PM (Central Daylight Time, UTC-05:00) #    Comments [2]  | 

 

CSLA Contrib #

CSLA Contrib is supposed to be a community for sharing CSLA tools, templates, and ideas.

http://www.codeplex.com/Wiki/View.aspx?ProjectName=CSLAcontrib

Worth checking out.

Categories: Programming | .Net
Sunday, July 23, 2006 12:48:39 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

YourOS web based operating system#

I saw a link from fark to www.YourOs.com which is supposed to be a web based operating system.  I tried to do a demo but it was too busy from the /. crowd.

This would be interesting to try, they say they have MP3 players, word processors etc.

Categories: Interesting
Sunday, July 23, 2006 12:29:52 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Resetting a PIX password#

Here is a quick trick for resetting a pix password:

http://www.tech-recipes.com/cisco_firewall_tips639.html

You need console access to do so.

Categories: Networking | Firewall | Security
Friday, July 21, 2006 1:25:58 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Here Is A Article Talking About The Ability To Put Some Of Your Config Info In Another Config File When Using Aspnet#

Here is a article talking about the ability to put some of your .config info in another config file when using asp.net

http://www.beansoftware.com/ASP.NET-Tutorials/Multiple-Config.aspx

What I found most interesting is that it says that changing the otherFile.config will not reset your app.

I am guessing that it also means that it won't find your new values until the app is reloaded, but if it DID find the new values w/o a reload that would be great.

<?xml version="1.0"?>
<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
        <compilation debug="false" strict="false" explicit="true" />
    </system.web>
    <appSettings file="externalSettings.config"/>
</configuration>

I also wonder if you could have more than 1 appSettings external file.

Categories: Programming | .Net | ASP.Net
Thursday, July 20, 2006 3:52:58 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Some Good Links For Updating Cisco PIX Devices#
Categories: Networking | Firewall | Security
Wednesday, July 19, 2006 4:01:43 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

All content © 2010, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<August 2006>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.3.9074.18820

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: