New Blogging Platform

by Mike Stephens 27. March 2008 13:56
I'm looking at potentially moving this blog to another blogging platform,   Any  "Free" suggestions are welcome.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Free Online Photoshop

by Mike Stephens 27. March 2008 08:54
I saw today that Adobe has released a Beta version of online Photoshop
I haven't tried it out yet but intend to once I get home.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Alt.Net Moniker

by Mike Stephens 7. June 2007 11:37
I was reading Jim's blog and ran across this post for Sam Gentile's blog and thought I'd repost it myself just because I think this is how I fit into the .Net world as well. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software Development

A whole slew of links to read

by Mike Stephens 4. June 2007 11:54
I was reading Scott Guthries blog today and came across this blog post from last week.   It has enough links in there to keep me busy for a week.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Microsoft Surface

by Mike Stephens 30. May 2007 21:26
So I saw the news about Microsoft Surface today.  Pretty cool indeed but it is certainly not new technology.  I saw this article over a year ago.   Hopefully Microsoft doing this will bring the touchscreen technology to the real user though, there are very cool things to be done with it but it is so expensive to implement.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

A take on the Apple comercials by RoR

by Mike Stephens 15. May 2007 13:31
Funny play on the Apple commercials.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Funniest Dilbert Ever

by Mike Stephens 15. May 2007 00:23
So today I was looking for the link to the funniest Dilbert strip I had ever seen and it had been removed.  So I searched long and hard and found an archived copy of it and linked it here.    Seriously,  the best ever. If you can't read it all click here.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Excel XML XMLSS Error Too Many Tags

by Mike Stephens 22. March 2007 14:29
So I recently had to write some code that would take some data and stick it in a pre-formatted (complicated) Excel spreadsheet.
I decided to use the XML format so I could easily do this without having to use the Excel COM object.
I had everything going good until I tried to open the file I was sending back through the browser twice in a row. 
I kept getting an Workbook error and looking in the log i saw this
XML ERROR in Workbook Setting
REASON:    Too many tags
FILE:    C:\Documents and Settings\Mike\Local Settings\Temporary Internet Files\Content.IE5\90LEWOHS\Results_3_22_2007[3].xml
GROUP:    Workbook
TAG:    Worksheet
ATTRIB:    Name
VALUE:    MyWorksheetName

Well the problem ended up being because Excel saw the same filename twice in a row it was trying to open the dataset being fed to it within the same open workbook.   Worksheet names must be unique within a Workbook so it was throwing the "Too many tags" error. 

My solution to this was just just add a short unique id to the end of the file name so Excel wouldn't recognize it as the same file and presto!  everything works as expected.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software Development

Clueless guy wants Windows XP Clone OS, Hacker Proof, < $3000

by Mike Stephens 1. March 2007 23:12
Title says it all,  this guy is nuts.  It just goes to show how little people know that aren't in the business of making software. I don't think most people even remotely have an idea of what it takes to make software.  This guy over at GetACoder.com wants someone to build an operating system that will do everything XP does, run all the programs XP does,  be completely hacker proof for less than $3000.   I should bid for $1000 bucks and put an Ubuntu cd in the mail with instructions on how to setup Wine.

Wouldn't it be great if people just realized that this stuff doesn't just magically appear.  I can say that I've spoken to a person or two that believes that everything is easy because even they know how to "code",  in HTML.
Below the description is an animated gif.  If you didn't catch it from the start just wait a second,  it will restart for you.

Budget: $ 1000-3000
Description
Hi,

So I'm posting for a rather large project. I need someone to program me a new OS (Operasting System) that looks different than Ms Windows XP etc. but has the same style. It does not need to run on a mac but all the other PCs. It's supposed to have a stylish look with clear edges etc. And ITS NOT SUPPOSED TO BE JUST A REDESIGNED WINDOWS as I'm going to sell that operating system later on. It's going to be called BlueOrb.

These are some important points :

It should have ALL THE FEATURES that Windows Xp Professional has.
ALL the files that run on Windows XP ust also run on the BlueOrb OS.
It must have a very user-friendly interface (like MS WINDOWS XP)
When it gets Installed, the user needs to insert a serial number.
It HAS to be HACKER SAFE!
It must be quick and good looking.

Animated GIF below.























Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

HTML Emails and Outlook 2007

by Mike Stephens 17. January 2007 16:39
The difficulties that I had posted about before have been picked up by some larger blogs and gotten quite a bit of notice.  I'm glad that I wasn't the only one that was frustrated by this

Microsoft takes email design back 5 years at CampaignMonitor.com

Microsoft breaks HTML email rendering in Outlook 2007 at SitePoint.com

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Programmer's Bill of Rights

by Mike Stephens 17. January 2007 15:42
Over at Coding Horror I found this post that describes a proposed programmer's bill of rights.  This is right on,  at a previous work place my team was afforded nearly none of this.   They put us in the most disruptive place in the building, right next to the manufacturing area with a wide open door.  They had the most uncomfortable chairs and asked us to use $2 KeyTronic keyboards, and a crappy mouse.  Now that I work at home these were the first things I fixed since I was able to create my own work environment.

Summary:
Every programmer shall have two monitors
Every programmer shall have a fast PC
Every programmer shall have their choice of mouse and keyboard
Every programmer shall have a comfortable chair
Every programmer shall have a fast internet connection
Every programmer shall have quiet working conditions

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Wiping a Harddrive

by Mike Stephens 6. January 2007 14:39
A few weeks ago my sister sold her computer on craigslist.  I had warned her she needs to fully wipe the hard drive before she actually sold it and suggested using GDisk which is what I am familiar with.  But she couldn't get access to the program and just fdisk'd it and formatted and and hoped for the best.  I ran across this post which is a free utility that will essentially do the same thing for you.  You just download it, burn it to cd and boot, the options are pretty simple, just type in autonuke and it will wipe the drive three times.  Thats enough to keep anyone that is only mildly interested in what might have been on the drive out.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Speed up FireFox and Internet Explorer

by Mike Stephens 17. December 2006 20:14
The default settings for Firefox and Internet Explorer are set pretty low so that they don't overwhelm older / slower computers.
Here are a couple things you can do to speed them up a lot.

Firefox:

Open Firefox, for the url type "about:config" and press enter.
This will open up a screen with lots of settings.
In the Filter box, type in "network.http",  this will shorten the list.
Find the key "network.http.pipelining" and set it to "true"
Find the key "network.http.piplining.maxrequests" and set it to 30. 
The default setting of 4 only allows 4 requests at a time, by setting it to 30 your browser can do much more work.
Press the "Show All" button on the upper right to show all the keys again.
In the Filter box, type in "nglayout.initialpaint.delay" and set it to 0.
If it does not exist just right click and select the New Integer and type in the name above.
This setting tells Firefox not to wait after receiving data to start rendering it.  The default setting in Firefox is 750ms.
So Firefox waits nearly a second after getting the data from the internet before displaying it.

Internet Explorer:

Go to your Start prompt and select "Run".
Type in "regedit" and press "Ok".
You will see a bunch of folders.
Navigate through the folders to "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
Right click and insert a new DWORD key with the name "MaxConnections Per1_0Server" and a Decimal value of 10.
Right click and insert a new DWORD key with the name "MaxConnections PerServer" and a Decimal value of 10.

There you go,  much faster browsers,  enjoy

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Net Neutrality Commercial

by Mike Stephens 16. December 2006 18:36
The telecommunication companies have been running some ads on TV lately that are flat out lies.   The first time I saw one I couldn't believe it,  how can they blatantly like to consumers like that?

For those who don't know what Net Neutrality is,  It is the telcos trying to get a slice of the pie that they don't own, nor should they, thats why they broke up ma' Bell all those years ago,  same thing is happening here, just with the internet instead of phone lines.  Basically every company out there that has a website pays money to their internet service provider for the bandwidth that is used to serve the website to web surfers.   Every consumer pays a monthly bill to their internet service provider that allows a certain amount of bandwidth to view websites.  What is going on is that the telecos realize that for years they have been adding surcharges, and equipment charges, and all sorts of stuff to penny pinch the consumer. They have now realized they want to do this with the internet.   Even though the companies and the consumers have already paid for the cost for equipment, bandwidth, etc to their service providers, they want to now charge for the specific kind of traffic that is traveling over their lines.  Remember,  YOU and the COMPANIES have already paid for the cost for traffic to travel over these lines.  So you use company A for your internet, the place you want to go to uses company B for their internet.  If company A does not have an agreement in place with company B to allow traffic to cross lines you can't see anything that uses company B for internet service.  Basically each company would charge other companies for any traffic that doesn't originate from their own service.  Thus allowing the telcos to charge once for you to connect to the internet, the companies that have websites to connect to the internet and  then charging everyone one again for a second time to actually putting traffic on it. Its like paying to drive on a toll road but you can only drive on the toll road if you buy all the gas for your car at the toll booth which they sell, even though the gas you bought down the road works just fine.  Pretty stupid huh?

Here is a youtube video that sums up what I explained before.  It would be great if this were made into a commercial that would be shown on nationally syndicated TV to let people who aren't tech oriented know what the companies are really trying to do, and show people how desperate the phone companies are.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

General | Software Development

Notorious "Access is denied" error for ASP.Net applications

by Mike Stephens 15. December 2006 20:07
So I have always had a problem occasionally with the "Access is Denied" error.  Usually cleaning out the bin folder bouncing the development server and restarting Visual Studio would fix this. (I made a nice little batch script)  I ran across a case where it wouldn't fix the problem.

After some searching I found out what is causing the problem.   Its the Indexing service locking the temporary ASP.Net files. 
Just go into your services console (Start->right click my computer->select manage-> click Services)  and locate the Indexing service and switch the startup type to manual and stop the currently running service.

Microsoft ticket is here

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software Development

Easy way to generate XML Documents with SQL Server: XML Explicit

by Mike Stephens 15. December 2006 00:03
On a project a few weeks ago a coworker introduced me to a very easy way to generate XML documents.  We were going to use it for a flat file to be distributed with a locally run application but the first thing that jumped to mind for me was AJAX applications.   I remember my first experience with writing an AJAX application and thinking their had to be a better way that looping through data that was returned to me.   Of course this was before you could store XML natively with SQL Server 2005. On to the show I suppose. 

The command I would like to introduce is the SQL command "XML Explicit".  At first glance many of the samples I saw seemed very complicated and it took me quite a few tries of experimentation to fully understand everything that was going on. Another reason why it can seem intimidating is that many people in the software world have become very comfortable with ORM tools and therefore their SQL skills get pretty rusty.  I have to admit that I was one of these people, my SQL skills were average but if you put something pretty complicated in front of me it would take me a bit to grasp it.   But since with my new employer I was thrust right into SQL world,  no fluffy ORM tools to help me now.

So lets say you have SQL database with a table for employees, departments, positions, etc. and you want put them into a nice flat file with all their information and who works for who. 
Employees
id name position reports_to skills
1 Tom Manager 1 Good with money
2 Brian Developer 5 C++, C, MFC, C#, VB.Net, Java, HTML, XML
3 Sharon Accountant 2 Good with money
4 Dave Developer 5 C#, VB.Net, Java, HTML, XML
5 Jim Manager 1 Tech oriented
6 Bob CEO 0 Good at running companies
7 Ron Manager 1 Creative marketing ideas


So we want to see an XML file that looks something like this:

<employees>
    <employee id="1" name="Bob" position="CEO">
       <skills>Good at running companies</skills>
        <employee id="2" name="Tom" position="Manager">
                <skills>Good with money</skills>
                <employee id="6" name="Sharon" position="Accountant">
                        <skills>Good with money</skills>
                </employee>
        </employee>
        <employee id="3" name="Jim" position="Manager">
                <skills>Tech oriented</skills>
                <employee id="7" name="Dave" position="Developer">
                       <skills>C#, VB.Net, Java, HTML, XML</skills>
                </employee>
                <employee id="8" name="Brian" position="Developer">
                      <skills>C++, C, MFC, C#, VB.Net, Java, HTML, XML</skills>
                </employee>
        </employee>
        <employee id="4" name="Ron" position="Manager">
                <skills>Creative marketing ideas</skills>
        </employee>
    </employee>
</employees>

Now on to the fun,  we are going to make this file using the XMLExplicit command. One of the links that helped me while I was learning how to use this was this article over at TopXML.com

To sum up the command it relies on making a "select" for each layer of your XML file and then unions all the different layers together.  There are two required tags that will have to be used, "tag" and "parent".  As you can probably imagine, they are used to define how the layers of your XML file are to be stacked. Here is a sample of the select for the root node, I will explain it below.

select
    top 1
    1 as tag,
    null as parent,
    null as [employees!1],
    null as [employee!2!id],
    null as [employee!2!name],,
    null as [employee!2!position],
    null as [employee!2!skills!element],
    null as [employee!3!id],
    null as [employee!3!name],
    null as [employee!3!position],
    null as [employee!3!skills!element]
from
    employees


Now this looks pretty scary at first glance but lets break it apart.   First lets look at defining how our XML document will work.
We will have 4 layers from outer most to  the inner most.  To define our root node we have this command [employees!1] where "employees" is the name of the element, "!" is a seperator, and "1" is the level of the node.  1 indicates that it is the outer most node.  Now to define each employee for the second list we use several commands [employee!2!id] represents part of the second layer.  "employee" is the tag name, "2" is the layer for it to be in, and "id" is the name of the attribute on the "employee" element to fill in.  We have several like this to define each of the attributes we want on the element.  To place a "skills" element within the employee element we use the notation "[employee!2!skills!element] where "employee" is the element name, 2 is the layer, "skills" is the name of the element within the employee element, and finally  "element" to indicate that it is an element instead of an attribute.

Now using the tag and parent sections we will define how each layer of the XML file will be organized.  The example below will show the outer most list of employees

select

    2 as tag,
    1 as parent,
    null as [employees!1],
    e.id as [employee!2!id],
    e.name as [employee!2!name],
    e.position as [employee!2!position],
    e.skills as [employee!2!skills!element],
    null as [employee!3!id],
    null as [employee!3!name],
    null as [employee!3!position],
    null as [employee!3!skills!element],
    null as [employee!4!id],
    null as [employee!4!name],
    null as [employee!4!position],
    null as [employee!4!skills!element]
from
    employees e
where
    e.reports_to is NULL


As you can see the second layer looks much like the one above.  Now the tag is set to "2" so that we will fill in the 2nd layer of the XML.  The parent tag is set to "1" to point back to the "employees" element we did a select for before. Each of the layer 2 attributes are now set to the value of the query. This will grab "Bob" the CEO element and put it in the XML doc.   In order to get our top layer node we say "where e.reports_to is null"  to get the "Bob" record and everything else will percolate down from the upper most layer.  The most important thing to remember when doing this is to keep your queries the same.   It is fine to do joins with additional tables but you must be absolutely certain that the same data is queried each time.  Now we need to select the employees for Bob and here is how we do it.

select

    3 as tag,
    2 as parent,
    null as [employees!1],
    e.id as [employee!2!id],
    null as [employee!2!name],
    null as [employee!2!position],
    null as [employee!2!skills!element],
    ee.id as [employee!3!id],
    ee.name as [employee!3!name],
    ee.position as [employee!3!position],
    ee.skills as [employee!3!skills!element],
    null as [employee!4!id],
    null as [employee!4!name],
    null as [employee!4!position],
    null as [employee!4!skills!element]
from
    employees e
inner join
    employees ee
on
    ee.reports_to = e.id
where
    e.reports_to is null


Again,  Nearly the same as above, with a few changes,  the tag and parent values are now set to reflect the 3rd layer, and it is below the second layer. If you notice now for the [employee!2!id] we have id there instead of null.   Now were looking for the "Jim" and "Ron" records.  So do do that we will query for the same data from before but do a another join for the "reports_to" is the value of the id on the node above it. Using this method you can easily and simply create XML documents from SQL server with no heavy lifting required. 

To put this all together you would now do a "UNION ALL" for each of your layers to combine them all together.  The last thing we have to do is define an ORDER BY clause.  This clause will sort the order that each layer is displayed.  It is very important that the elements that you ORDER BY are included in the results of all the selects.   So in this instance it would be the "id" of each employee.

ORDER BY
    [employee!2!id], [employee!3!id],[employee!4!id]
for xml explicit, type

Now some trouble shooting tips.  You are going to run into an error saying that "Tag # is not open".  Its just gonna happen, so here are the things to check for.  First,  Make sure that data exists at all layers that a sublayer exists for.  Second,  Verify that any of the ORDER BY clauses are included in all the queries.  If one of them does not exist it will throw this error. 

I hope you learned something from this and let me know if there are any questions or comments.  Here is a copy of the query in total.

SET NOCOUNT ON;
select
    top 1

    1 as tag,
    null as parent,
    null as [employees!1],
    null as [employee!2!id],
    null as [employee!2!name],
    null as [employee!2!position],
    null as [employee!2!skills!element],
    null as [employee!3!id],
    null as [employee!3!name],
    null as [employee!3!position],
    null as [employee!3!skills!element],
    null as [employee!4!id],
    null as [employee!4!name],
    null as [employee!4!position],
    null as [employee!4!skills!element]
from
    employees


UNION ALL

select

    2 as tag,
    1 as parent,
    null as [employees!1],
    e.id as [employee!2!id],
    e.name as [employee!2!name],
    e.position as [employee!2!position],
    e.skills as [employee!2!skills!element],
    null as [employee!3!id],
    null as [employee!3!name],
    null as [employee!3!position],
    null as [employee!3!skills!element],
    null as [employee!4!id],
    null as [employee!4!name],
    null as [employee!4!position],
    null as [employee!4!skills!element]
from
    employees e
where
    e.reports_to is NULL

UNION ALL

select

    3 as tag,
    2 as parent,
    null as [employees!1],
    e.id as [employee!2!id],
    null as [employee!2!name],
    null as [employee!2!position],
    null as [employee!2!skills!element],
    ee.id as [employee!3!id],
    ee.name as [employee!3!name],
    ee.position as [employee!3!position],
    ee.skills as [employee!3!skills!element],
    null as [employee!4!id],
    null as [employee!4!name],
    null as [employee!4!position],
    null as [employee!4!skills!element]
from
    employees e
inner join
    employees ee
on
    ee.reports_to = e.id
where
    e.reports_to is null

UNION ALL

select

    4 as tag,
    3 as parent,
    null as [employees!1],
    e.id as [employee!2!id],
    null as [employee!2!name],
    null as [employee!2!position],
    null as [employee!2!skills!element],
    ee.id as [employee!3!id],
    null as [employee!3!name],
    null as [employee!3!position],
    null as [employee!3!skills!element],
    eee.id as [employee!4!id],
    eee.name as [employee!4!name],
    eee.position as [employee!4!position],
    eee.skills as [employee!4!skills!element]
from
    employees e
inner join
    employees ee
on
    ee.reports_to = e.id
inner join
    employees eee
on
    eee.reports_to = ee.id
where
    e.reports_to is null

ORDER BY
    [employee!2!id], [employee!3!id],[employee!4!id]
for xml explicit, type


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software Development

Practices for sending HTML emails to various email providers

by Mike Stephens 13. December 2006 19:17
I was recently asked to write some code that would generate multi-part plain text / HTML emails for distribution. I knew there would be some issues between the major providers, Outlook, Outlook 2007, Gmail, Yahoo, Hotmail but I had no clue as I came to find out. The standard method I've used for generating some basic templates was to just mark it up in a html file and use that as a template and replace the key fields as went along and attach a css style element for each individual customer.   Thank you Gmail and Outlook 2007 for completely eliminating the <style> tag, making my life a pain.

So my next instinct was to google for a solution because someone has found their way around all this before, right?  After a bunch of reading pretty much the only way to format stuff in gmail was to use tables and to apply a very limited subset of formatting options to the <td> tag. Yahoo and Hotmail and Outlook 2003 seem to fully render my emails as expected.

Right now my current plan is to aim for using a rich text editor for the clients to use to apply inline styles to the specific message.  I have not yet tested this but this is the behavior that is claimed. If they do not want to use this rich text client they should be able to paste the contents of a Word doc that has been saved as an HTML type into the source of the editor and get the markup in that fashion.  In the future I might allow an upload of an HTML doc, stripping the "bad" tags of course and allowing them to use that.

Here is a list of useful links that have helped me immensely while researching this. 

xavierfrenette.com has a great article on all the different services and techniques
campaignmonitor.com has some more tips for users based upon the tips from the link above
sitepoint.com has a  good article by Tim Slavin
mailchimp.com has some more good tips and even samples to download
reachcustomersonline.com has some good basic tips and lots of links to other tips

The other big one you should know about is that Microsoft Office 2007 has changed their rendering engine from previous versions.  They have changed it from using an IE rendering engine to one based upon Word 2007.  This eliminates most everything that Gmail does.  They have a couple articles to inform you of the new standards and a validation tool you can download and install on Visual Studio 2005, Expression Web Designer or Dreamweaver. The validation tool works well but the only complaint that I have is that it requires you manually edit some registry entries.  If they require me to run an msi to use the validator they should at least modify the registry for me since its dirt simple to do.

Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 1 of 2)
Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 2 of 2)
2007 Office System Tool:  Outlook HTML and CSS Validator

I will give an update if I find a better solution.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software Development

Need to see how to do something in Javascript?

by Mike Stephens 13. December 2006 15:17
I just saw that Google has released their Google Web Toolkit available open source.
I have only browsed everything this tool kit can do in the past but now that it is open source I went in and viewed many of their functions.   Bound to be a good resource for how to do things.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software Development

A Take On Working From Home

by Mike Stephens 13. December 2006 09:40
Over at the Web Worker Daily there is an article that largely sums up many practices that I find it takes to work at home. 
Much like the author I get the same question repeatedly asked, "How do you work at home, I would be so distracted?"  Just like the author I typically find myself not having that problem, but the exact opposite one.   When do I stop working or it'll only take a few more minutes that turn into hours.  Working at home definitely blurs the line on my time and company time and I have to admit, its been one of the hardest things to nail down about working from home.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software Development

Page Large Datasets with SQL Server

by Mike Stephens 10. December 2006 13:34
I recently came across a problem where I was going to be using huge datasets.  Potentially 100k+ records that would be displayed in a data grid.   Since the built in paging in the Asp.Net Data Grid sucks so bad I was going to come up with a different method that would use sql to do all my work.    I ran across an article on 4GuysFromRolla and worked from there.  Its a great solution and extremely fast.

Basically all you do is to declare a new table in your stored procedure,  add an identity column, and a column that will link to the primary key of your dataset you want to return. Now you can do a select on your dataset with your order by clause to sort your data and insert each record in your other table based on your row count to get for the page size and the last record index. On the code end of things you just have to keep track of the last index you retrieved and the size of the page you want returned.
CREATE  PROCEDURE [dbo].[usp_PageResults_NAI] 
(
@startRowIndex int,
@maximumRows int
)
AS

DECLARE @first_id int, @startRow int

-- A check can be added to make sure @startRowIndex isn't > count(1)
-- from employees before doing any actual work unless it is guaranteed
-- the caller won't do that

-- Get the first employeeID for our page of records
SET ROWCOUNT @startRowIndex
SELECT @first_id = employeeID FROM employees ORDER BY employeeid

-- Now, set the row count to MaximumRows and get
-- all records >= @first_id
SET ROWCOUNT @maximumRows

SELECT e.*, d.name as DepartmentName
FROM employees e
INNER JOIN Departments D ON
e.DepartmentID = d.DepartmentID
WHERE employeeid >= @first_id
ORDER BY e.EmployeeID

SET ROWCOUNT 0

GO

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Software Development

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

My name is Mike Stephens and I am a Software Developer in Milwaukee, WI but origionally from Texas

Tag cloud

    Page List