Back to the drawing board

by John 14. December 2011 06:41

Well, as much as I would love to stay with my current company, sometimes things just don't always line up the way we hope.  Guess I'll be reading all those emails from recruiters and auto-listings from Dice and CareerBuilder now. *sigh*

Tags:

General

T-SQL Utility

by John 5. December 2011 06:18

Here's a handly little routine that will generate INSERT statements from the data in a supplied table.  I wrote this a long time ago and don't often need to use it these days, but when security restricts me from doing any sort of actual table export/import between servers yet that's what I need to do, this is extremely useful.

 

DECLARE @ColName varchar (100) 
DECLARE @colType varchar (100) 
DECLARE @Output varchar (8000)
DECLARE @TableName varchar(50)

SELECT @TableName = '{table_name_here}'

SELECT @ColName = '', @ColType = '', @Output = ''

DECLARE rs CURSOR FOR
	SELECT c.Name,	t.Name
	FROM
		sysobjects o 
		JOIN syscolumns c ON o.ID = c.ID 
		JOIN systypes t	ON c.xType = t.xType
	WHERE
		o.Name = @TableName 
	
OPEN rs 

FETCH NEXT FROM	rs INTO @ColName,@ColType 

--build the field listing...
IF  @@Fetch_Status = 0
SET	@outPut = 'SELECT ''INSERT INTO ' + @TableName + ' (' 

WHILE @@Fetch_Status = 0
BEGIN
SELECT @output = @output + char ( 10 ) + '	' + @colname + ', ' 
	
FETCH NEXT FROM	rs INTO @ColName, @ColType
END
CLOSE rs 

--remove the trailing ', '
SELECT @output = Left(@output, Len(@output) - 1) 

--now build the values list
OPEN rs 
FETCH NEXT FROM rs INTO @ColName, @ColType 

--build the field listing...

IF @@Fetch_Status = 0
SET	@outPut = @output + char(10) + ') VALUES (' 

WHILE @@Fetch_Status = 0
BEGIN
SELECT @output = @output + char ( 10 ) + '	' + 
	CASE
		WHEN  @ColType IN ( 'varchar' , 'char' , 'smalldatetime' , 'timestamp' , 'datetime' , 'nvarchar' , 'nchar' ) 
			THEN ''''''' + replace(ISNULL(' + @ColName + ',''''),'''','''''''') + '''''
		ELSE ''' + convert(varchar,ISNULL(' + @ColName + ',0)) + '
	END

SELECT @output = @output + ''', '
FETCH NEXT FROM rs INTO @ColName, @ColType
END

CLOSE rs 
DEALLOCATE rs 

--remove the trailing  ', '
SELECT @output = Left( @output,Len( @output) - 2)

SELECT @output = @output + ''')''' 
--now we've completed the complicated SELECT clause, just close up the FROM

SELECT @output = @output + Char(10) + 'FROM ' + @TableName

--SELECT @output 
EXEC(@output)

 

Tags: , , , ,

SQL Server

XML Serialization With Custom Namespace Attributes

by John 27. April 2011 05:16

So, after a bit research, I discovered that my brain wasn't working well.  It completely passed me by that the prefix for the attribute names was actually a namespace. With that, I was able to modifiy the property declaration and there's my namespace-prefixed attributes!

<System.Xml.Serialization.XmlAttributeAttribute([AttributeName]:="file", Namespace:="bb", Form:=System.Xml.Schema.XmlSchemaForm.Qualified)> _
Public Property file() As String
        Get
                Return Me.fileField
        End Get
        Set(ByVal value As String)
                Me.fileField = value
        End Set
End Property

Which produced the XML:

<resource xml:base="RSRC4" bb:file="RSRC4.dat" bb:title="New Item" identifier="RSRC4" type="bb-x-doc"  />

Tags: , ,

VB

Custom XML Serialization Question

by John 26. April 2011 05:50

Hello all. I have an object model, a series of classes and whatnot, that needs to be serialized into an XML document. I have all of this working just wonderfully, except for one thing. One of the classes, called Resource, has properties for Filename, Title, Base which need to serialized as attributes named "bb:file", "bb:title" and "xml:base" respectively. When I add to the property declaration, the serializer works just fine, but if I add a 2nd one to either of the other 2 properties, I get an error stating "There was a reflection error in the serializer." - on the line where I create the serializer object; but no further information is available. test code Here is the code of the class:

<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=True)> _
Partial Public Class Resource

Private fileField As String

Private titleField As String

Private identifierField As String

Private typeField As String

Private baseField As String

<System.Xml.Serialization.XmlAttributeAttribute([AttributeName]:="xml:base", Form:=System.Xml.Schema.XmlSchemaForm.Qualified)> _
Public Property base() As String
Get
Return Me.baseField
End Get
Set(ByVal value As String)
Me.baseField = value
End Set
End Property

'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Qualified)> _
Public Property file() As String
Get
Return Me.fileField
End Get
Set(ByVal value As String)
Me.fileField = value
End Set
End Property

'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Qualified)> _
Public Property title() As String
Get
Return Me.titleField
End Get
Set(ByVal value As String)
Me.titleField = value
End Set
End Property

'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public Property identifier() As String
Get
Return Me.identifierField
End Get
Set(ByVal value As String)
Me.identifierField = value
End Set
End Property

'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public Property type() As String
Get
Return Me.typeField
End Get
Set(ByVal value As String)
Me.typeField = value
End Set
End Property
End Class

And here is the code I use to create the serializer:

Dim xmlserializor As New Xml.Serialization.XmlSerializer(GetType(BBXSD.Manifest))

Using stream As New IO.FileStream(_outputFile, IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite)
xmlserializor.Serialize(stream, objManifest)
stream.Close()
End Using

Manifest is the "parent" class that contains a property reference to an array of Resource class objects. (this is structured this because if I use a collection or list it doesn't get serialized properly).

Any thoughts anyone has would be most welcome.

Tags: , , ,

VB

Certification Bug

by John 23. February 2011 05:16

Everytime someone mentions certification, I get all amped up to get certified again.  I got my MCSD (Microsoft Solution Developer ... for Visual Studio 6.0) back in 1999, and while it didn't give me superpowers, it was certainly nice to have that little graphic on my resume.  That certification has long since expired, and with each new version of Visual Studio, I am constantly reminded of just how "out of date" I am.  

This morning, I was asked if I knew my MCP ID, and it reminded me that I have been meaning to look into certification again, now that my company has a training budget reimbursement program.  It's always a little more incentive to complete when someone else is picking up the tab.  Weird how that works. lol

Well, so I went out to the MCP site and started poking around the tests, requirements, etc and found the process is still very much the way it was 10 years ago; only now things are more expensive.  And, as usual, Microsoft doesn't even offer training materials for all of the tests. Specifically, the Windows Communication Foundation (70-513) MCTS test.  No e-books, no self-paced training kits, just a 3 day course that costs far too much and yields far too little information. Similarly, the final exam to get the MCPD certification, is the test: PRO: Designing and Developing Web Applications (70-519); which also has no training materials other than a FIVE day training course.

Now for the big dilema: Do I get the self-paced training books or the interaction practice tests?  In the past, I've used the books along with the practice tests with decent success.  The books are a nice precursor and the practice exams (at least the Transcender exams) provided a more "real life" test, and gave high detailed results, along with information relating to each and every question - if it's wrong, if it's right, why it's wrong or right.  I don't have a lot of spare time on my hands, so whichever I get will be a long and random process; it could take, perhaps even a year for me to get the certifications (I hope not, but I've known people who haven that long).  Also, books cost half of what the practice tests cost; although I expect (hope) the practice tests are more thorough and a better overall preparation.

Now, granted, I am looking at certification materials for VS 2010, not 2008, so it's a bit newer and it could take some time to get them released, but still, there's no mention of when the new testing materials might be released.

However, here's why I don't like looking into certification.  Here's a practice test question:

An ASP.NET page contains the following markup:
<asp:EntityDataSource ID="dataSource" runat="server" 
ConnectionString="name=EntityConnection" 
DefaultContainerName="AccountingEntities" EnableFlattening="False" 
EntitySetName="Invoices" 
Select="it.[InvoiceNumber], it.[Amount]"> 
</asp:EntityDataSource> .

blah blah blah rest of the question.

I don't know of a single programmer who uses scripted datasource objects in their web forms, yet all the documentation and courses teach that method.  It reminds me that being an MCP only means that I've learned how to take the tests; but has no bearing in the real world.  So, each time I think about getting certified, I end up talking myself out of it.  However, I know the market value for certified people and employers do like abbreviations after your name...

Guess I'll buy a book and see how it goes; then re-evaluate the situation.

Tags: , ,

General | Programming | .Net

What's The Point

by John 16. February 2011 04:45

Someone recently asked me what the point of this blog is.  That's a fair question.  There are hundreds of other tech blogs - most far more technical than this one.  The reason I started this is because every once in a while, I run across something that just strikes my fancy in such a way that I would love to share it.  It could be something I did which I consider to be excellent, it could be something "Dilbert-ish", or it could be something I read that I find share-worthy.

When I post little code snippets, they're one of two things: awesome or entertaining.  Like that little blurb of HTML in the last post.  I mean seriously, p - b - br - /b /p  no text, no labels, no placeholder, no names, no... anything.  That's just hilarious to me.  Maybe I'm too sarcastic to be a programmer? 

Every programmer who has ever been around the block has run into situations where they find themself in a situation which could drive you crazy.  If you don't find a way to deal with it, you will lose it and bad things happen. This blog is an outlet of sorts for me.  

Recently I've been talking about working with some older code.  I don't have a problem with that, but I'd be lying through my teeth if I didn't look at this stuff and remember all the times I spent writing this exact same type of stuff.  Because I've written thousands of lines of the same code, I feel justified is pointing it out in a mocking manner - because I'd be laughing at my own code if I ran across that too. Think about it: How many hours (over the years) have web developers wasted going back through their HTML source to capitalize their tags because that was the standard?  An awful lot.  Now, lowercase is the standard, so when VSIDE starts complaining about XHTML 4.0 compliancy, I just have to laugh.

I laugh because I find it entertaining just how little we programmers stick to our guns.  I'm quite sure that when CAPITALIZATION was the standard, those standard-mongers would go to war over a lowercase anchor tag.  When M$ said "oops, that looks terrible... um... the new standard is lowercase." those same people were the first to write RegEx scripts to parse through all that html and replace A with a.  If the next standard is UpAnDdOwN, I'm sure we'll have hundreds of RegEx's that do just that as well.

As much as I'd love to just do what I know, do what I did best, I can't. No full-time programmer can.  If we did, we'd be out of a job.  We have to evolve, adapt and overcome our own standards to adhere to what the marketplace wants.  I, personally, despise the idea of ending all lines with a semicolon. I hated it in Turbo Pascal, and I hate it in C# - but the difference is, now I get paid to put those semicolons in; and that makes all the difference.  I would prefer not to, but what I want and what the market wants don't always align.  I understand that - and I think any programmer that's been around longer than a few years understands that.  Especially as consultants, we are (or should be) the code-generating equivalent of Mystique.  We conform to whereever we are and however it's done there.  It doesn't mean we aren't still people with our own brand of humor, sarcasm, faith or lifestyle; it just means that the longer we're in this business, the more we become that old man in the bar who's been everywhere, behind the scenes, seen the show and saw the strings.  We should be happy to be that person because that means we've had a nice long run - and hopefully still running.

Tags: , ,

General

You Know You're Working With Old Code When...

by John 14. February 2011 11:10

Visual Studio IDE highlights e.v.e.r.y.t.h.i.n.g. in the source code when you open it up.

hahaha

Also, what's this do:

<p><B><br>
    </b></p>

*snicker*

 

Tags:

General

The Geek Is Strong With This One

by John 9. February 2011 10:07

This is more entertaining than anything else.  Over this past weekend, I slept in late, woke up, got coffee went to check my email and before my 2nd cup of coffee I was formatting the hard drive on my old desktop and installing Win2k3 server.  At the end of the day, I had a new Active Directory server also running IIS 6 with multiple websites.  I guess it's also a file server of sorts, since I have no use for the other 80gb drive in that box.  heh  It's important to note that my plan for the day was laundry and video games; neither of which require building a new domain controller.

Tags: , ,

General

How Not To Keep A .Net Developer Amused

by John 4. February 2011 10:01

I'm no spring chicken, but I'm no dinosaur either.  However, I have been around long enough to remember when using HTML templates and populating them in some server-side compiled DLL was all the rage in high-powered web development; a precursor even to VB6's WebClasses.  Do any of you remember the ridiculous hype those WebClasses received - particularly at VBITS 1998 (maybe it was 99, I'd have to check my tote bag to be sure)?  Well, anyway, it was super-duper showcased.  All the power of VB6 in a dll, but still running on a webserver, serving up html pages like pancakes at an IHOP.

 

Now, do you remember actually doing any real development with those webclasses? I bet most of you tried it, realized the one major flaw, and quickly abandoned the technology.  If you wanted to make so much as a single character edit to the HTML page, you had to recompile the DLL, stop/start the MTS package hosting the DLL and most likely stop/start the IIS website as well.  Not exactly the most developer friendly deployment scheme.

 

Now... imagine that same situation, but instead your code engine is Power Builder.  Add to that, an enormous amount of Javascript, some of it custom, the rest as part of old js-based menu system (Joust - remember?).  For that extra little topper, toss in multiple framesets.  Ooh, that's right. I said it. I said frames.  HOW COOL where frames when we got HTML 3.2?!? Oh man, they were the best thing ever.  How many corporate websites ran on frames? Just about all of them.

 

The point to all of this reminiscing is that some places have not realized the sins of the past and still, to this very day, run setups exactly as described above.  I know this because my newest client site is one of those places.  Yes. A major entity in the area is powered by classic asp, powerbuilder, javascript and frames (not even iFrames, real life frames. You remember:

 

<frameset cols="100%" rows="72,*">
	<frame name="title"   src="/webap_buildTitlePage.htm"  scrolling='no'   marginwidth='0' marginheight='0' APPLICATION='yes' noresize>
	<frame name="menu"    src="/webap_plan_menu.htm"  scrolling='auto' marginwidth='0' marginheight='0' APPLICATION='yes'>
</frameset>

 

Yep. It must be one of the dirtiest secrets in all of this city's IT departments.

 

Now, for the title of this post... I was recently handed, literally, hand-delivered 40 (FORTY) printed pages of Power Builder code and told to use this a guide to replace one function of a classic web app with a new .net page.

 

I understand the department doesn't have the resources or time for a full site redesign, development, etc... but this is not the first time we've tried this "lets replace this one function with .net and stay on the migration path" idea.  I'm reminded of the adage: "The road to hell is paved with good intentions." Yes, it's good to start thinking about moving away from PB/JS solutions, but trying to do it in this patchwork style only leads to bad things.

 

Oh, and lastly, when you deliver this stack of wasted paper and explain how you were the lead architect for the system 12 years ago and still brag on its flexibility and power, maybe you should realize that you've hired a "new age tech guy" to replace all of that stuff and this isn't your hayday anymore.  

 

It's a cold, harsh truth that, especially in IT, the *moment* you think you're finally ahead of the curve, you realize you've just been lapped.  I'm still fighting to stay in the race and as proud as I am about some of my past victories, I certainly would not expect any one of them to still be around today. 

Tags: , , , , , ,

Programming | .Net

Flash Tag Cloud and BE 2.0

by John 3. February 2011 07:04

As I'm building the blog site up, adding widgets, extensions, etc, I'm becoming more and more familiar with how things work.  I like this. I'm able to offer some small guidance in the discussion forums; which is always nice.  Most recently, I tried to add the Flash Tag Cloud widget.  I should say I did because it is there.  I said tried because initially I couldn't get it to work at all.  Then I went through the BE-supplied Breaking Changes list and realized I had forgotten to make the changes to the widget's source code.  So, finally, when I added the widget, it appeared.  However, there were no tags floating around. I edited the settings on the widget several times, but no avail. Nothing was working.  Then, after about 20 mins of trying different themes, settings, double-checking source code, it occurred to me.  Tag clouds often don't list every-single-tag-ever-used; commonly it's the most oft-used tags.  So, I created several new posts, duplicating existing tags and voila! My tag cloud was there, populated, spinning and all awesome-like.

So, just a note to any other wpCumulus-based-BE-widget users... make sure you have plenty of posts/tags for your widget to read, otherwise you might be staring at a blank white box. heh Now, I just gotta come up with some more legit posts to get that widget working. 

Tags: , , ,

General

About Me

I'm a .Net developer in St. Louis, MO working for Ferguson Consulting. 

Professional Info

Tag cloud