Send e-mail with attachment from database image column (sql server 2k5)

Soooo...I needed to get files out of my SQL Server table (which has the files in an image column) and attach them to an email to send out.  I honestly thought this would be a no-brainer but turned out it was pretty finicky.  Anyway...the code to so is below just in case anyone is wondering.

    Function SendEmail()

        'Get your data (filename, content type, image column) from the db

        Dim dt As DataTable = GetYourStuff()

 

        If dt.Rows.Count <= 0 Then Return Nothing

 

        Dim msg As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()

        msg.Subject = "Sample Message"

        msg.To.Add(New System.Net.Mail.MailAddress("Receiver@yourDomain.com"))

        Dim fromadx As New System.Net.Mail.MailAddress("Sender@yourDomain.com", "Sender Name")

        msg.From = fromadx

        msg.IsBodyHtml = False

        msg.Body = "Sample body..."

 

        Dim strMem As System.IO.MemoryStream = New System.IO.MemoryStream(CType(dt.Rows(0)("ImageColumn"), Byte()))

        Dim strWriter As System.IO.StreamWriter = New System.IO.StreamWriter(strMem)

        strWriter.Flush()

 

        'this is very important..wont work without it

        strMem.Position = 0

 

        'Filename and content type are hardcoded here, but I assume you get them from GetYourStuff() above

        Dim attachment As System.Net.Mail.Attachment = New System.Net.Mail.Attachment(strMem, "myFile.txt", "text/plain")

        msg.Attachments.Add(attachment)

        Dim smtpClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings.Item("smtpserver"), 25)

        smtpClient.Send(msg)

    End Function

Alternatives to FindControl()?

Alright, as much as I try to avoid using FindControl() sometimes I need to get a control by its ID.  I came across what seems like a good idea here : http://www.thescripts.com/forum/thread269592.html

It's in C#, but here is the VB.NET adaptation...

  549     Private Sub BuildControlHashTable()

  550         Dim cName As String = String.Empty

  551         For i As Int16 = 0 To Me.Controls.Count - 1

  552             cName = Me.Controls(i).ID

  553             If Not (cName Is Nothing) Then

  554                 cntrlHashTbl.Add(cName, Me.Controls(i))

  555             End If

  556         Next

  557     End Sub

  558     Private Function GetControlByName(ByVal cntrlName As String) As Control

  559         Return CType(Me.cntrlHashTbl(cntrlName), Control)

  560     End Function


Good idea? Bad idea? Thoughts?


Export to vCard from .NET (VB.NET)

Hi all -
So was poking around a few weeks ago and couldn't find any code that'll allow me to export data to vcard...The class would require a little modification to utilize, but should get you 90% of the way there

Partial Class vCardExport

Inherits System.Web.UI.Page

Private Const nameFirst As String = "FirstName"

Private Const nameLast As String = "LastName"

Private Const nameMiddle As String = "MiddleName"

Private Const nameTitle As String = "Mr"

Private Const email As String = "firstname.lastname@domain.com"

Private Const uRL As String = "www.geekswithblogs.net/sanjayu"

Private Const telephone As String = "555 555 5555"

Private Const fax As String = "555 555 5555"

Private Const mobile As String = "555 555 5555"

Private Const company As String = "My Company"

Private Const department As String = "My Department"

Private Const mtitle As String = "My Title"

Private Const profession As String = "My Profession"

Private Const office As String = "227"

Private Const addressTitle As String = "New York"

Private Const streetName As String = "42nd Street"

Private Const city As String = "New York"

Private Const region As String = "Northeast"

Private Const postCode As String = "00000"

Private Const counTry As String = "USA"

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

eVCard.VCard(Response, nameFirst, nameLast, nameMiddle, nameTitle, email, uRL, telephone, fax, mobile, company, department, mtitle, profession, office, addressTitle, streetName, city, region, postCode, counTry)

End Sub

End Class

Public Class eVCard

Inherits System.ComponentModel.Component

 

 

Public Shared Sub VCard(ByVal response As HttpResponse _

, ByVal nameFirst As String _

, ByVal nameLast As String _

, ByVal nameMiddle As String _

, ByVal nameTitle As String _

, ByVal email As String _

, ByVal uRL As String _

, ByVal telephone As String _

, ByVal fax As String _

, ByVal mobile As String _

, ByVal company As String _

, ByVal department As String _

, ByVal title As String _

, ByVal profession As String _

, ByVal office As String _

, ByVal addressTitle As String _

, ByVal streetName As String _

, ByVal city As String _

, ByVal region As String _

, ByVal postCode As String _

, ByVal counTry As String)

response.Clear()

response.Charset = ""

response.ContentType = "text/x-vCard"

Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()

Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)

stringWrite.WriteLine("BEGIN:VCARD")

stringWrite.WriteLine("VERSION:2.1")

stringWrite.WriteLine("N:" + nameLast + ";" + nameFirst _

+ ";" + nameMiddle + ";" + nameTitle)

stringWrite.WriteLine("FN:" + nameFirst + " " + nameMiddle _

+ " " + nameLast)

stringWrite.WriteLine("ORG:" + company + ";" + department)

stringWrite.WriteLine("URL;WORK:" + uRL)

stringWrite.WriteLine("TITLE:" + title)

stringWrite.WriteLine("ROLE:" + profession)

stringWrite.WriteLine("TEL;WORK;VOICE:" + telephone)

stringWrite.WriteLine("TEL;WORK;FAX:" + fax)

stringWrite.WriteLine("TEL;CELL;VOICE:" + mobile)

stringWrite.WriteLine("EMAIL;PREF;INTERNET:" + email)

stringWrite.WriteLine("ADR;WORK;ENCODING=QUOTED-PRINTABLE:" + ";" + _

office + ";" + addressTitle + "=0D" + streetName + ";" + _

city + ";" + region + ";" + postCode + ";" + _

counTry)

stringWrite.WriteLine("END:VCARD")

response.Write(stringWrite.ToString())

response.End()

End Sub

End Class

"Cannot drop the queue 'SqlQueryNotificationService-{GUID}', because it does not exist or you do not have permission."

Working on my first SQL 2K5 application here...and came across this error trying to implement the SqlNotificationService.  I read a lot on this error...However, I was able to avoid this error by simply making the current user of own the DB. 

1. Security > Users > [select the user your application is accessing the DB as]
2. Select properties (right click)
3. Find and check your DB schema in the list of "Owned Schemas"
4. Ensure "DB Owner" is checked off in the "Role Members" list

That's it...

SqlSiteMapProvider in VB.NET

Alright, so I wanted to build a dynamically/DB driven role-based menu system utilizing framework 2.  I started with this article… http://msdn.microsoft.com/msdnmag/issues/06/02/WickedCode/

 

And then converted to VB.NET…Not to come across some items that I needed to change…

 

I came across the following errors:

“'System.Web.Caching.CacheItemRemovedCallback' is a delegate type and requires a single 'addressof' expression as the only argument to the constructor”

 

Which required this line “New CacheItemRemovedCallback(AOnSiteMapChanged))” in the BuildSiteMap() function to be changed to “New CacheItemRemovedCallback(AddressOf OnSiteMapChanged))”  No biggy.

 

Then there was some funky stuff going on with NULL values (mainly in the “description” and “parentID” columns”  Turns out there was a bunch of this going on..

 

Dim title As String = IIf(reader.IsDBNull(_indexTitle), Nothing, reader.GetString(_indexTitle).Trim())

 

Which was freaking out because of the NULL values (see http://weblogs.asp.net/psteele/archive/2003/10/09/31250.aspx)

 

So I added a simple function “CheckNullRefs” to account for that. 

 

Lastly, it looks like the “Roles” property from SqlSiteMapProvider was actually giving me the _number_ of roles assigned to a siteMapNode rather than a collection of the actual roles themselves.  So for example roles=”2” instead of

roles{0}=”Users”

roles(1)=”Admin”

 

I added a public array list, and then added the line below to the “CreateSiteMapNodeFromDataReader” function. 

roles = ArrayList.Adapter(rolelist)

 

I’m sure there is a more elegant way to do all of this…but figured this would be helpful since I found little to no info on it by googling. 

 

Update! I had a, uhm, "feature" in my code..the signature of the ReplaceNullRefs was wrong (was accepting ByVal rdrVal As String instead of Integer.  Thanks to Benjamin Howarth for pointing this out!

Update 9/20:  I've updated the ReplaceNullRefs function below, thanks Rob!


This allows me to dynamically build my menu by doing the following in the MenuItemDataBound sub

    Protected Sub PublicMenu_MenuItemDataBound(ByVal sender As Object, ByVal e As MenuEventArgs)

        'Users can be in multiple groups so...if the roles attribute of a siteMapNode contains one of the roles that a user belongs to

        'do not remove it.  Remove all others.

        If (UserRoleName.Length) < 1 Then

            UserRoleName = Roles.GetRolesForUser()

        End If

        Dim blmRemoveRole As Boolean = True

For i As Integer = 0 To UserRoleName.Length - 1

            If CType(e.Item.DataItem, System.Web.SiteMapNode).Roles.Contains(UserRoleName(i)) Then

              

                blmRemoveRole = False

                Exit For

            End If

        Next

 

        If blmRemoveRole Then

            If e.Item.Parent Is Nothing Then

                Me.MainMenu.Items.Remove(e.Item)

            Else

                e.Item.Parent.ChildItems.Remove(e.Item)

            End If

        End If

 

    End Sub

 

Imports System

Imports System.Web

Imports System.Data.SqlClient

Imports System.Collections.Specialized

Imports System.Configuration

Imports System.Web.Configuration

Imports System.Collections.Generic

Imports System.Configuration.Provider

Imports System.Security.Permissions

Imports System.Data.Common

Imports System.Data

Imports System.Web.Caching

 

''' <summary>

''' Summary description for SqlSiteMapProvider

''' </summary>

<SqlClientPermission(SecurityAction.Demand, Unrestricted:=True)> _

Public Class SqlSiteMapProvider

    Inherits StaticSiteMapProvider

    Private Const _errmsg1 As String = "Missing node ID"

    Private Const _errmsg2 As String = "Duplicate node ID"

    Private Const _errmsg3 As String = "Missing parent ID"

    Private Const _errmsg4 As String = "Invalid parent ID"

    Private Const _errmsg5 As String = "Empty or missing connectionStringName"

    Private Const _errmsg6 As String = "Missing connection string"

    Private Const _errmsg7 As String = "Empty connection string"

    Private Const _errmsg8 As String = "Invalid sqlCacheDependency"

    Private Const _cacheDependencyName As String = "__SiteMapCacheDependency"

 

 

    Private _connect As String

    ' Database connection string

    Private _database As String, _table As String

    ' Database info for SQL Server 7/2000 cache dependency

    Private _2005dependency As Boolean = False

    ' Database info for SQL Server 2005 cache dependency

    Private _indexID As Integer, _indexTitle As Integer, _indexUrl As Integer, _indexDesc As Integer, _indexRoles As Integer, _indexParent As Integer

    Private _nodes As New Dictionary(Of Integer, SiteMapNode)(16)

    Private ReadOnly _lock As New Object()

    Private _root As SiteMapNode

    'Added...Declare an arraylist to hold all the roles this menu item applies to

    Public roles As New ArrayList

 

 

 

    Public Overloads Overrides Sub Initialize(ByVal name As String, ByVal config As NameValueCollection)

 

        ' Verify that config isn't null

        If config Is Nothing Then

            Throw New ArgumentNullException("config")

        End If

 

        ' Assign the provider a default name if it doesn't have one

        If [String].IsNullOrEmpty(Name) Then

            Name = "SqlSiteMapProvider"

        End If

 

        ' Add a default "description" attribute to config if the

        ' attribute doesnt exist or is empty

        If String.IsNullOrEmpty(config("description")) Then

            config.Remove("description")

            config.Add("description", "SQL site map provider")

        End If

 

        ' Call the base class's Initialize method

        MyBase.Initialize(Name, config)

 

        ' Initialize _connect

        Dim connect As String = config("connectionStringName")

 

        If [String].IsNullOrEmpty(connect) Then

            Throw New ProviderException(_errmsg5)

        End If

 

        config.Remove("connectionStringName")

 

        If WebConfigurationManager.ConnectionStrings(connect) Is Nothing Then

            Throw New ProviderException(_errmsg6)

        End If

 

        _connect = WebConfigurationManager.ConnectionStrings(connect).ConnectionString

 

        If [String].IsNullOrEmpty(_connect) Then

            Throw New ProviderException(_errmsg7)

        End If

 

        ' Initialize SQL cache dependency info

        Dim dependency As String = config("sqlCacheDependency")

 

        If Not [String].IsNullOrEmpty(dependency) Then

            If [String].Equals(dependency, "CommandNotification", StringComparison.InvariantCultureIgnoreCase) Then

                SqlDependency.Start(_connect)

                _2005dependency = True

            Else

                ' If not "CommandNotification", then extract database and table names

                Dim info As String() = dependency.Split(New Char() {":"c})

                If info.Length <> 2 Then

                    Throw New ProviderException(_errmsg8)

                End If

 

                _database = info(0)

                _table = info(1)

            End If

 

            config.Remove("sqlCacheDependency")

        End If

 

        ' SiteMapProvider processes the securityTrimmingEnabled

        ' attribute but fails to remove it. Remove it now so we can

        ' check for unrecognized configuration attributes.

 

        If config("securityTrimmingEnabled") IsNot Nothing Then

            config.Remove("securityTrimmingEnabled")

        End If

 

        ' Throw an exception if unrecognized attributes remain

        If config.Count > 0 Then

            Dim attr As String = config.GetKey(0)

            If Not [String].IsNullOrEmpty(attr) Then

                Throw New ProviderException("Unrecognized attribute: " + attr)

            End If

        End If

    End Sub

 

    Public Overloads Overrides Function BuildSiteMap() As SiteMapNode

        SyncLock _lock

            ' Return immediately if this method has been called before

            If _root IsNot Nothing Then

                Return _root

            End If

 

            ' Query the database for site map nodes

            Dim connection As New SqlConnection(_connect)

 

            Try

                Dim command As New SqlCommand("proc_GetSiteMap", connection)

                command.CommandType = CommandType.StoredProcedure

 

                ' Create a SQL cache dependency if requested

                Dim dependency As SqlCacheDependency = Nothing

 

                If _2005dependency Then

                    dependency = New SqlCacheDependency(command)

                ElseIf Not [String].IsNullOrEmpty(_database) AndAlso Not String.IsNullOrEmpty(_table) Then

                    dependency = New SqlCacheDependency(_database, _table)

                End If

 

                connection.Open()

                Dim reader As SqlDataReader = command.ExecuteReader()

                _indexID = reader.GetOrdinal("ID")

                _indexUrl = reader.GetOrdinal("Url")

                _indexTitle = reader.GetOrdinal("Title")

                _indexDesc = reader.GetOrdinal("Description")

                _indexRoles = reader.GetOrdinal("Roles")

                _indexParent = reader.GetOrdinal("Parent")

 

                If reader.Read() Then

                    ' Create the root SiteMapNode and add it to the site map

                    _root = CreateSiteMapNodeFromDataReader(reader)

                    AddNode(_root, Nothing)

 

                    ' Build a tree of SiteMapNodes underneath the root node

                    While reader.Read()

                        ' Create another site map node and add it to the site map

                        Dim node As SiteMapNode = CreateSiteMapNodeFromDataReader(reader)

                        AddNode(node, GetParentNodeFromDataReader(reader))

                    End While

 

                    ' Use the SQL cache dependency

                    If dependency IsNot Nothing Then

                        HttpRuntime.Cache.Insert(_cacheDependencyName, New Object(), dependency, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, _

                         New CacheItemRemovedCallback(AddressOf OnSiteMapChanged))

                    End If

                End If

            Finally

                connection.Close()

            End Try

 

            ' Return the root SiteMapNode

            Return _root

        End SyncLock

    End Function

 

    Protected Overloads Overrides Function GetRootNodeCore() As SiteMapNode

        SyncLock _lock

            BuildSiteMap()

            Return _root

        End SyncLock

    End Function

 

    ' Helper methods

    Private Function CreateSiteMapNodeFromDataReader(ByVal reader As DbDataReader) As SiteMapNode

        ' Make sure the node ID is present

        If reader.IsDBNull(_indexID) Then

            Throw New ProviderException(_errmsg1)

        End If

 

        ' Get the node ID from the DataReader

        Dim id As Integer = reader.GetInt32(_indexID)

 

        ' Make sure the node ID is unique

        If _nodes.ContainsKey(id) Then

            Throw New ProviderException(_errmsg2)

        End If

 

        ' Get title, URL, description, and roles from the DataReader

        Dim title As String = ReplaceNullRefs(reader, _indexTitle)

        Dim url As String = ReplaceNullRefs(reader, _indexUrl)

 

        'Eliminated...see http://weblogs.asp.net/psteele/archive/2003/10/09/31250.aspx

        Dim description As String = ReplaceNullRefs(reader, _indexDesc)

 

        'Changed variable name from 'roles' to 'rolesN' and added line 230 to dump all roles into an arrayList

        Dim rolesN As String = IIf(reader.IsDBNull(_indexRoles), Nothing, reader.GetString(_indexRoles).Trim())

       

 

        Dim rolelist As String() = Nothing

        If Not [String].IsNullOrEmpty(rolesN) Then

            rolelist = rolesN.Split(New Char() {","c, ";"c}, 512)

        End If

        roles = ArrayList.Adapter(rolelist)

 

 

        ' Create a SiteMapNode

        Dim node As New SiteMapNode(Me, id.ToString(), url, title, description, rolelist, _

         Nothing, Nothing, Nothing)

 

        ' Record the node in the _nodes dictionary

        _nodes.Add(id, node)

 

        ' Return the node       

        Return node

    End Function

 

    Private Function ReplaceNullRefs(ByVal rdr As DbDataReader, ByVal rdrVal As Integer) As String

        If Not (rdr.IsDBNull(rdrVal)) Then


            ' Thanks Rob Johnston

            Return rdr.GetString(rdrVal)

        Else

            Return String.Empty

        End If

    End Function

 

    Private Function GetParentNodeFromDataReader(ByVal reader As DbDataReader) As SiteMapNode

        ' Make sure the parent ID is present

        If reader.IsDBNull(_indexParent) Then

            '**** Commented out throw, added exit function ****

            Throw New ProviderException(_errmsg3)

            'Exit Function

        End If

 

        ' Get the parent ID from the DataReader

        Dim pid As Integer = reader.GetInt32(_indexParent)

 

        ' Make sure the parent ID is valid

        If Not _nodes.ContainsKey(pid) Then

            Throw New ProviderException(_errmsg4)

        End If

 

        ' Return the parent SiteMapNode

        Return _nodes(pid)

    End Function

 

    Private Sub OnSiteMapChanged(ByVal key As String, ByVal item As Object, ByVal reason As CacheItemRemovedReason)

        SyncLock _lock

            If key = _cacheDependencyName AndAlso reason = CacheItemRemovedReason.DependencyChanged Then

                ' Refresh the site map

                Clear()

                _nodes.Clear()

                _root = Nothing

            End If

        End SyncLock

    End Sub

End Class

My Resignation

Well, that's all folks.  I've resigned my position. 

Not an easy call, not an easy call at all but I've been offered a position at a large media-firm that I simply cannot pass up.  So, that's the plan...Leave familiarlity for a new opportunity, new challenges, and new surroundings...namely, the thick of manhattan. 

If nothing else, it will certainly be exciting. 

 

ASP 3.0 / snipps that i need to keep on hand

Yes, it's time for some ASP 3/Classic content.  Okay, I confess, this post is mostly just a reminder for myself in the future...but I assume at some point someone will come across this via google....

I was wondering what the easiest way to traverse a recordset was (not most performant, necessarily...just simplest in terms of me saving time)  I commonly see people actually writing out the table and then explicitly defining which column goes where.  You know, something like:

objRs(0) objRs(1)

Which, really, is kind of a pain in the arse.  You could just do something like this if it's just a simple output to a table, and not really worry about too much HTML, provided your query columns are in the order you want them displayed.

  SearchString = “whatever..“
  Set objRS = objConnection.Execute(SearchString)
 
  Do While Not objRS.EOF
   i = i + 1
   if i mod 2 = 0 then varClass = "light" else varClass = "med" 'just to change styles...
  
    for x=0 to objRS.Fields.count-1
     response.write "

" & objRS(x) &""
    next
    
   response.write ""
   objRS.MoveNext
  Loop

Another handy bit of code for debugging request() parameters is the following.  Much easier than actually response.write() -ing all the variables out manually...

For x = 1 to Request.Form.Count 
    Response.Write Request.Form.Key(x) & " = " 
    Response.Write Request.Form.Item(x) & "
"

Next

Here is an easy one for populating select lists...

Sub PopulateSelectOptions(ByVal objRecordset, ByVal varCurrentID, varBlankLine)
 Dim varHTML
 Dim varSelected
 
 If Not objRecordSet.EOF Then objRecordSet.MoveFirst
  If varBlankLine Then varHTML = "<OPTION VALUE=0></OPTION>" Else varHTML = ""
   Do While Not objRecordset.EOF
    If Not IsNull(varCurrentID) Then
     If CLng(varCurrentID) = Clng(objRecordset.Fields(0)) Then
      varSelected = " SELECTED"
     Else
      varSelected = ""
     End If
  Else
   varSelected = ""
  End if
  
  varHTML = varHTML & "<OPTION VALUE=" & objRecordset.Fields(0) & varSelected & ">" & objRecordset.Fields(1) & "</OPTION>"
  objRecordset.MoveNext
 Loop
 If IsNull(varHTML) And Len(varHTML) < 0  Then
  varHTML = "<OPTION>-No-</OPTION>"
  Response.Write varHTML
 Else
  Response.Write varHTML
 End if
End Sub

IIS 6 with ASP 3.0 / ASP Classic

At first, I thought migrating a classic ASP app formally running on win2k/IIS5 would be a 5-10min no brainer.  Here I am approximately 2 hous later, and I just got it working. 

So after you do all the basic stuff like create your virtual directory, and install your db client software..this is the tricky part

I received the following error:

oracle ADODB.Connection error '800a0e7a'

This is what resolved it for me:

1. Log on to Windows as a user with Administration privileges.
2. Launch Windows Explorer from the Start Menu and navigate to the ORACLE_HOME folder. This is typically the "Ora92" folder under the "Oracle" folder (i.e. D:\Oracle\Ora92).
3. Right-click on the ORACLE_HOME folder and choose the "Properties" option from the drop down list. A "Properties" window should appear.
4. Click on the "Security" tab of the "Properties" window.
5. Click on the "Authenticated Users" item in the "Name" or "Group or user names" list.
6. Uncheck the "Read and Execute" box in the "Permissions" or "Permissions for Authenticated Users" list under the "Allow" column.
7. Re-check the "Read and Execute" box under the "Allow" column (this is the box you just unchecked).
8. Click the "Advanced" button and in the "Permission Entries" list make sure you see the "Authenticated Users" listed there with:
Permission = Read & Execute
Apply To = This folder, subfolders and files
9. I checked the "Replace permission entries on all child objects with entries shown here that apply to child objects" checkbox and clicked the "Apply" button. (This was not specified in the original instructions, but it worked.)
10. Click the "Ok" button until you close out all of the security property windows. The cursor may present the hourglass for a few seconds as it applies the permissions you just changed to all subfolders and files.
11. Reboot your computer to assure that these changes have taken effect.
12. Re-execute the application and it should now work.

 

How to approach technical interviews

Great link...Definitely applies to getting a technical job outside of Silicon Valley...Check it out if you have a few.

http://blog.guykawasaki.com/2006/08/the_inside_scoo.html

Code Sharing / Code Snippets Sites

Came across a link to http://www.ProgrammingIsHard.com on www.dZone.com  So I figured I'd list some of the code sharing & code snippet sites I've come across as of late. 

http://www.codeplex.com/ (MS's site)

http://www.bigbold.com/snippets/

http://www.krugle.com/

http://snipplr.com./

Got any others I should know about?  Cheers

Some development opinions :0

Okay.  This may be somewhat a rant...so, you have been warned. 

I've noticed a lot of people get obsessed with performance.  This is kind of okay, provided your code is working.  I know people (we won't name names!) that will just fret on performance before the method they want to write even exists.  Perhaps this is just my point-of-view, but isn't it better to get X piece of code taking the proper input(s) and delivering the proper output(s), first?  You can get hung up on performance and refactor to your heart's content - but get it working first, please.

Second.  Don't go crazy typing before you think about anything.  Comment the process first, don't type any code.  When you're done, make sure the logic makes sense.  Why spend time coding something only to realize it doesn't even make sense after you just typed 30 lines of code?

Perhaps I've bene a bit more on-edge about this stuff since I've been reading the pragmatic programmer lately. 

Have a nice day :)

Copy source as HTML

Found this neat tool from Colin Coller.  Basically, let's you copy code as HTML (right-click option) in VS.NET 2k3/5.  Handy for posting code to the web!

Localhost blocked? Changing the default debug address in VS.NET 2k5

Greetings. So I ran into a bit of an annoying challenge today. For months now, I've had IIS installed locally. I work on my local project/sln's, and save them - then update to our source control server  Everyone was happy for awhile there.  Anyway, I guess security made some modifications to our AD Security Policy, so if I try to reach http://localhost/Projects/Whatever I'm pretty much out of luck.  In any case, you can subvert this in VS.NET by modifying your .CSPROJ file.

<WebProjectProperties>
          <UseIIS>False</UseIIS>
          <AutoAssignPort>True</AutoAssignPort>
          <DevelopmentServerPort>1899</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl></IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
</WebProjectProperties>

All I did was change the UseIIS from False to True - and then add the URL I'd prefer to use in IISUrl.  Pretty straightforward, me thinks. I'm not sure if there is a menu within VS.NET 2k5 to do this w/o editing the XML here - If there is, I certainly haven't found it.  Let me know if you can shed some light on this.

Cheers.

Excellent Link

Greetings,  Long time no post :) Anyway, I found this excellent link to the “Top 10 Developer libraries”  These includes JavaScript libraries, Cascading Style Sheet (CSS) libraries, AJAX associated libraries, a site that helps you pick color schemes (Good for the design impaired programmers...I won't name any names. coughMEcough), and of course DHTML libraries. 

I found these over on www.dZone.com - if you haven't checked out/heard of this site yet, it's worth a look-see.  Basically, it's a digg style sites exclusively for developers.

Ajax Animated GIFs

Hey all,

Came across two great resources for using/generating animated GIFs for your AJAX enabled projects...

The first one is a site that dynamically generated animated GIFs for your use...

The second is control that lets you display a "wait message". It's best to check out the demo on this. A neat feature of this is the ability to display the "wait message" during a page_load. This control reminds me of this.