Wednesday, November 02, 2005

.NET 2.0 Custom Build Providers

Wow this is soooooooo cool I can't believe it!

How would you fancy NOT having to write a DataAccess layer in your apps but instead to get the ASP.NET 2.0 engine to automatically serve the code to you straight from the Database Structure?

If you don't understand the problem, you need to spend a bit more time creating by hand (not allowed to cheat with CodeSmith or other...):

  • Tables
  • Views
  • Stored Procedures
  • .NET Data Access Code that calls everything and performs SELECT, INSERT, UPDATE and DELETE...

Then you will know what I mean especially if your DB has 250 tables, 150 Views and 640 Stored Procedures!!!

I was lucky enough to come across this article from Fritz Onion and I think it is absolutely awesome. Fritz you're a genius man!

Using that idea, I have been able to build a code generator that creates my DataAccess layer automatically from the Database, then in my code I only need to reference the relevant object and call methods against them like:

Dim objProfile as Profile

objProfile.ID = "1"

objProfile.Name = "Test Name"


How cool is that!!!

Tuesday, August 23, 2005

HtmlInputFile problem uploading large files!

God I have spent nearly 4 days solid trying to work that one out!

Here is the challenge:
Basically there is by a size limit to the file you can upload to a webserver using the good old HtmlInputFile Input. By default this limit is 4Mb and it is set in the machine.config file on the web server:

httpruntime maxrequestlength="8192"

It is of course possible to override this value in your web.config file and make it web app specific.

The problem occurs when you try to upload something bigger than that... you will get a nasty DNS error because the worker process got its knickers in a twist on the webserver. It basically reached a memory threshold before it could do anything with the file!

A full explanation can be found here:;en-us;295626

Anyway the bottom line is that it displays a nasty error to the user and the people I work for don't like that at all.

As a Google group lover I looked for an answer to that one for a lot longer than I originally thought I would have to and finally found this EXCELLENT article by Jesse Chunn:

Jesse you're the man! The little code snippet you posted is awesome in simplicity and it works great.

The trick is to use the global.asax file and to test the file contentLength for every single request made to the web server.

I post the code again:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)

' Fires at the beginning of each request
Dim i As Integer

'this number is in bytes, NOT kilobytes!!
Dim iMaxFileSize As Integer = 8000000
For i = 0 To Request.Files.Count - 1
If Request.Files.Item(i).ContentLength > iMaxFileSize Then
Response.Redirect("FileToBig.aspx?filesize=" & Request.Files.Item(i).ContentLength)
Exit For
End If

End Sub

A massive thank you to you my friend, you're a star in the developer's world!!!

Friday, August 12, 2005

Enterprise Library, not always the best option!

I had to say it, the Enterprise Library which I think is a brilliant repository of coding practices from Microsoft, is not always the best option!

I struggled a lot with it when trying to deploy it to a shared hosting environment and I finally gave up. I had to write this on the GotDotNet Message board:

"Enterprise Library and shared hosting
Posted on: 08/12/2005 02:11:21

Hi guys, ok I have now developed 2 reasonably big ASP.NET applications built on the Enterprise Library. One of them uses Data Access, Configuration, Caching and Security (DB) and the other one uses the Data Access and Caching. They are both intranets and although it took me quite some time to suss out how to get everything to work and to code/debug my VB.NET calls to the EL, I finally managed to get the sites working very well and I am quite impressed with some of the functionality in EL.

However I have to emphasize on the fact that I did struggle, it is not always developer friendly and you have a few obstacles to overcome (I guess it's still quite new so people are getting used to it!) and even though it is packed with very cool functionality I still think it is a sledgehammer to crack a nut. Compared to the old DAAB and the ever so friendly SqlHelper class, there is quite a big gap! Maybe you should think about the Enterprise Library Lite! (.NET Framework 2.0?)

The Enterprise Library is awesome when it comes to hosting a very complex web app yourself on your very powerful W3K Server on an AD Domain. But when your designing a very simple secure site hosted on a shared hosting environment with a simple SQL server backend, like it is the case 99% of the time (for me anyway), you are in for a big ride!!! No way I could run "InstallServices.bat" on the 3rd party shared hosting network of course, so you get the nice "Access Denied error" when you try to run the blocks because of the Instrumentation and Logging trying to access the EventLog...

I read Tom's blog:

Tried what he suggested but was still getting errors from the Caching block even after turning off the Instrumentation altogether. After many hours of frustration, I just chose to give up, got rid of EL DLLs altogether and replaced them with the good old SqlHelper! Rewrote my data access layer, implemented a simple SQL server authentication mechanism with password encryption and swore I would never use EL again.

So end of story for me, a lot of time wasted, no will to get a dedicated server solution (too expensive) and therefore back to a normal plain old SqlHelper class, which I have to say now I kind of prefer to the EL!

At least it deploys to any server.

Sorry guys but I had to say it! On a different note, I still think the Enterprise Library Code is probably one of the best open source I have seen in terms of architecture and new ways of thinking blocks. Just make sure it is developer friendly and that you can deploy it to any .NET environment, especially remote with limited access rights!

Cheers, Etienne "

Wednesday, May 18, 2005

Crystal reports for .NET

I have just found some extremely useful info on how to implement and easily generate fantastic looking reports from within the VS.NET IDE!

Check this out!

Thanks to Josh Robinson I have also been able to plug the Crystal Report Viewer to the almighty MS Enterprise Library Data Access block!!!

For that you need to use strongly typed datasets and Josh explains how to do that in a very simple and clear way:

Josh you're the man!

Wednesday, April 13, 2005

Classic ASP Datagrid class

Classic ASP Datagrid class
Originally uploaded by Etienne L.
To complete my posting of the ASP.NET User Control datagrid, here is the older version...

This is a classic ASP datagrid implementing a hell of a lot of functionality and making sure everything is in a class and no images are required.

Basically only an include and some dead simple code can display data from a datasource on a webpage.

This example includes:

* Sorting
* Paging
* Styling (CSS)

I will post the code as soon as I have some space somewhere...

ASP.NET User Control Datagrid

ASP.NET User Control Datagrid
Originally uploaded by Etienne L.
This is an example of my latest ASP.NET user control datagrid. I will post the code for it very soon... only need to clean it up a bit.

This is NOT a server control (dll), it's simply an .ascx file. Dead easy. The features I have implemented are:

* Easy column sorting
* Paging (page numbers or triangles, no images required)
* Alternate coloring
* Custom ItemDataBound and ItemCommand events
* CSS Styles for the look and feel

It's not the most amazing one I have ever seen but it does the job extremely well and I use it all over my latest project!

Code will follow very soon...

Tuesday, April 05, 2005

Golden Shortcuts...

As a developer, you constantly have to use keyboard shortcuts to save time and to impress your colleagues ;)

There is the obvious ctrl+x, ctrl+c and ctrl+v that I use 1000 times a day, the ctrl+s (save), alt+tab, alt+shift+tab, ctrl+F4 (close inside window), alt+F4 (close window)... and so on.

Actually let me put a list of the ones I use constantly and tell me if you can think of others:
ctrl+x = cut
ctrl+c = copy
ctrl+v = paste
ctrl+z = undo
ctrl+y = redo
ctrl+b (with text highlighted) = make bold
ctrl+F4 = close inside window
alt+F4 = close window
alt+tab = switch to next app
alt+shift+tab = switch to previous app
shift+click (on URL in IE) = open URL in new window
ctrl+s = save
ctrl+shift+s = save all
F5 (in Query Analyzer) = execute (highlighted text or ALL if nothing highlighted)

But there is also the gold dust, shortcuts that take you years to work out and things you had no idea existed... and today I found one!!!

The first one that I did find about a year ago answers the question "How do you make a field NULL in SQL Server using the entreprise manager manual data edit within table?" the answer is to put the cursor in the relevant field (that you want to blank out) and press ctrl+0 (number "zero"). I have to say, I was pleased to finally get that one after years of "UPDATE tablename SET field = NULL WHERE ID = 11111"!

Today is one of those days where I am happy to add a new addition to my list of favourite shortcuts, the one I'm on about is probably one that VB developers like me will find extremely useful! It is ctrl+k and c or ctrl+k and u! What is it for are you going to ask... well have you ever tried to turn 50 lines of uncommented code to comments in VB?

It takes about 2 minutes to rem it, and 3 to rem it out cause you need to work out what lines are real code and what should remain comments.

ctrl+k and c will comment any highlighted text (multiple lines) in VS.NET!!! The other uncomments it... how brilliant is that!

For those who are anal like me about windows shortcuts, here is a VERY extensive list

Hope this helps! Happy shortcutting!...

Friday, March 04, 2005


Have you ever wanted to create a really cool DHTML menu automatically generated from an XML file (treeview) without having to worry about any of the code... but if you wanted to change the code/styles for whatever reason you could!!!

This is an amazing little ASP.NET open source app with an online GotDotNet community that rocks! I wish I had seen this before. It's already in the new project I am working on.

Awesome, brilliant work guys!!!

skmMenu Homepage

Friday, February 25, 2005


I am trying Firefox, the alternative browser for the first time today.
It looks good and seems to be packed with cool ideas...


I like the "BlogThis" Extension, which I am using to post this blog!

I will keep you up to date with my findings!

Thursday, February 24, 2005


Let me introduce myself, I am a French guy living in the UK since 1998, I am now 29... nearly 30.

I have been working with computers since I was about 12 and programming in basic on a Sinclair ZX 81!!! Originally it had 1Kb of RAM but I soon extended that to a massive 16Kb !
After that I went to Amstrad CPC 6128 with a... floppy disk. That was a big improvement from tapes.

Of course and just like everyone interested in computers I then acquired a PC. learnt DOS and was amazed when I first saw Windows 3.11 running on a 30Mb Hard drive... 95 was another biggy and NT the ultimate OS. I have to say, for my sins, I have always used Microsoft technologies to develop. I like user friendly and good looking stuff, I try and avoid command lines... unfortunately it's not always possible! :o)

Anyway, I am now swimming in the .NET pool and developing professional applications for various people in the UK. My main skills lie definitely in ASP.NET, VB.NET and SQL Server 2000 (learning Yukon as well, but as always, it's just the same as before, with more functionality!!!). I have to say I became very good at my job and there is no challenge so far that I have not been able to break (touch wood). With computers, everything is possible and the creative power is endless. When you build a house, you need bricks, mortar, contractors, tools... it takes time and a lot of effort. On the web you can create a site in no time, you are the man, all the tools and pretty much available for free and you can also learn to build a bigger and better looking house if you want to! The best thing if we keep this analogy with houses, you can change the color of your roof with a single mouse click :o)

I am starting this blog to share my technical thoughts & findings. All to do with code, .NET computers and the Internet.

I hope you enjoy it and that it brings some answers to your questions!

First Post

That's it, I'm no longer a blog virgin! What a feeling...
Let's see what we can do with this new amazing power!!!

The world is now mine ;o)