.Net ramblings
# Thursday, 17 July 2008
Euro symbol character problems...
if you ever send a string across a web service, and write it out to a file, make sure you specify Encoding.UTF8 explicitly. otherwise characters such as the EURO symbol may not render correctly in some browsers (IE6).  it took me ages to pin this down, because everything i read about was about HTTP header charset values, or HTML document charsets, or database encodings.  In my case i was using the default encoding and this messed up EURO symbols. I suspect it is because of the string being serialized in the web service, but haven't the time to look into it any further.  it's fixed now anyhow.


Thursday, 17 July 2008 17:25:32 (GMT Daylight Time, UTC+01:00)  #    Comments [3]  .Net General | Asp.Net

# Friday, 09 May 2008
SQL: String Split Function
I don't know why this isn't part of the built-in functions, especially in sql 2005 but anyway, here it is thanks to this groups post:
CREATE FUNCTION Split(@String varchar(4000), @Delimiter char(1))
RETURNS @Results TABLE (ID int, Items nvarchar(4000))
AS

BEGIN
DECLARE @INDEX INT
DECLARE @SLICE nvarchar(4000)
DECLARE @ID int

SELECT @INDEX = 1, @ID = 1
WHILE @INDEX !=0

BEGIN
-- GET THE INDEX OF THE FIRST OCCURENCE OF THE SPLIT CHARACTER
SELECT @INDEX = CHARINDEX(@Delimiter,@STRING)
-- NOW PUSH EVERYTHING TO THE LEFT OF IT INTO THE SLICE VARIABLE
IF @INDEX !=0
SELECT @SLICE = LEFT(@STRING,@INDEX - 1)
ELSE
SELECT @SLICE = @STRING
-- PUT THE ITEM INTO THE RESULTS SET
INSERT INTO @Results(ID, Items) VALUES(@ID, @SLICE)
SELECT @ID = @ID + 1
-- CHOP THE ITEM REMOVED OFF THE MAIN STRING
SELECT @STRING = RIGHT(@STRING,LEN(@STRING) - @INDEX)
-- BREAK OUT IF WE ARE DONE
IF LEN(@STRING) = 0 BREAK
END
RETURN
Then you can do something like this:
select Items from dbo.Split(@List, ',')


Friday, 09 May 2008 12:40:24 (GMT Daylight Time, UTC+01:00)  #    Comments [6]  Database

# Thursday, 01 May 2008
SonicWall Global VPN Client, Acquiring IP...
Trying to get SonicWall Global VPN Client working on vista, i kept getting stuck at "Acquring IP".  Adding the program to the windows firewall made no difference, nor did opening port 443 as has been suggested by others.  What did work was disabling IPv6 on the virtual adapter. 
Start->Control Panel->Network and Internet->Network and Sharing Center->Mange network connections page. Select SonicWALL Virtual Adapter and right click on properties.  Untick IPv6 and you should be good to go.  i didn't have to configure my router or anything to get this to work.

Update Sept 2008

Install the latest client from Sonicwall and this problem goes away, the virtual network adapter is automatically disabled when not in use.

Thursday, 01 May 2008 16:09:52 (GMT Daylight Time, UTC+01:00)  #    Comments [5]  General

# Friday, 11 April 2008
setting up a data connection using VS Emulator and Cellular Emulator
there is a good post by Jim Wilson about configuring the Cellular Emulator with a Visual Studio emulator.  it wasn't immediately obvious to me why anyone would need 'another' emulator running at the same time, until i read that the Cellular Emulator is actually a virtual radio chip for the phone, so you can use the phone as if you were on a 2G or 3G connection, and track the GPRS byte usage.  the thing is, it wasn't really obvious (to me) how to get the data connection working. the answer is rather simple but i'm posting it here in case i forget.

You follow the steps outlined by Jim, and then go into the VS emulator and set up a new ISP connection, using "Cellular GPRS/3G", just like you would on a normal WM6 device.  use a blank APN, username and password and you're good to go.


Friday, 11 April 2008 10:55:11 (GMT Daylight Time, UTC+01:00)  #    Comments [0]  Mobile

# Tuesday, 08 April 2008
disable hibernation in vista
powercfg -h off
run this as an administrator from the command prompt.  thanks to Mitch Tulloch for his post.


Tuesday, 08 April 2008 16:27:37 (GMT Daylight Time, UTC+01:00)  #    Comments [0]  General

# Saturday, 29 March 2008
Running Vista on a Laptop with 8Gb DIY SSD
I have this ancient laptop, a Celeron 2.4Ghz thing with 768 Ram, but it has a good screen and good battery life so i use it primarily as a remote desktop terminal with O2 3.5g broadband when i'm away from the office, which is great. but it's a slow old thing and it takes forever to boot.  i'll get a new laptop as soon as SSD's become more reasonably priced, i.e. in about 6-9 months, but until then...

Solid State Disks

i'm very interested in the emergence of Solid State Disks and how in my opinion they will remove the last bottleneck in the modern PC: the mechanical hard drive.  You can have the fastest processors and RAM in the world, and you'll still be staring at your computer waiting for stuff to happen because the hard drive is slow. 

To get your taste buds tickled, have a read of this excellent article from Next Level Hardware showing what a 9 SSD drive RAID array can do (at cost of $7000).

Then to come back down to earth have a read of this other excellent article by Kevin O'Brien that shows how to build a SSD drive out of compact flash cards, at a small cost, and still get really good performance to beat the pants off your old laptop hard drive.  I've followed Kevin's approach, but want to document it a bit further in terms of setting up a laptop running Vista on a 8Gb compact flash card. 

Hardware

For the laptop, I've ordered a dual compact flash to IDE adapter, 44 pin laptop style, and a 8Gb 300x compact flash card.  For my desktop i got 2x 4Gb 300x compact flash cards, and a quad CF-IDE adapter made by addonics, i intend to use this to store the swap file and other files from my desktop.  I got the flash cards from komplett.ie at 36 euro each for the 4Gb cards and 75 euro for the 8Gb card.  It's important to get the 266x or 300x cards in order to get the 40+Mb/sec transfer rates, anything less and it won't really be worth the effort.  I ordered the CF/IDE adapters from WebConneXXion.com at 25 euro (notebook dual version) and 37 euro (PCI quad version), unfortunately shipping to dublin was 40 euro but hey.  The hardware bits are still in the post so in the meantime i've set to work on creating a Windows Vista installation that can run inside an 8Gb disk.

Vista / vLite

As you probably know, Vista is a big mamma when it comes to hard disk space and memory requirements. But there is a great tool called vLite which lets you strip off the bits you don't want/need which make it a very lean OS for an old machine, and in this case, one with limited hard drive space.  With vLite you create a new Vista install image with your customised options and then install it on your laptop or whatever.  But that also means you can use the image to test out in a Virtual PC environment which is great, you can configure an 8Gb hard drive, 768Mb Ram, etc.  After removing all the components i don't think i'll need, my install ISO is only 732Mb, so far so good.  It is Vista ultimate by the way, here is my vLite ini file if you're interested.  I installed it to virtual PC and it took up 3.12 Gb including a 1Gb swap file, so a 2.12Gb install size is fairly good given that we have 8Gb to play with.  For general use, i will need AVG antivirus, Office 2007 (access, excel, word, ppt), Visual Studio Professional 2008, VLC Media Player and of course FireFox.  After installing all this the drive has 5.36 Gb used (including the swap file), with still plenty of space left over. 

Results on Laptop

Well i'm delighted to say that my laptop runs like a champ now, even though i was about to dump it!  vista boots in about 12 seconds, and applications load up very snappy.  the lack of grinding noise still amazes me.  i had no idea that a 4200 RPM drive was such a drag on system performance, it is quite remarkable.  battery life seems about 10% better with the SSD, although it was a fairly inaccurate test. i kept the screen on and a browser page reloading every 10 seconds (over wifi) untill windows shut itself down at 3% battery, this lasted 3 hours 10 mins. the great thing about this is that i can keep on using my laptop for another year or so and when i do upgrade i will be able to get something thinner and lighter, and which will definitey have a proper SSD! 

Results on Desktop

I have installed the RAID card with the 2x4Gb flash cards and i can get ~50 Mb/s continuous read benchmarks, but it took a bit of fiddling to get the best combination of card slots. 
my first combination of slot 1 and 2 gave a very poor benchmark with a 20Mb/s read at the start and end of the drive, maxing out at 50 in the middle. 

the Addonics support guy told me to put both cards on the same IDE controller so use port 1 and 3 but that was even worse:


so i tried port 3 and 4 on the back of the card and that gives a steady 50Mb/s read benchmark, which is pretty good:
theoretically 80Mb/s should be possible with a RAID 1 array of 2xCF v4 cards but 50Mb/s isn't bad, and the important thing is obviously the ~1ms seek time instead of 8ms for my raptor drive.  Interestingly the slot 1+2 combination gave access times of .7ms but the other combinations give 1.4 or 1.6ms, possibly due to master/slave issues with the IDE controllers.










Saturday, 29 March 2008 17:09:45 (GMT Standard Time, UTC+00:00)  #    Comments [2]  

Network Performance Problems With Vista
If you are having network performance problems with Vista, have a read of this useful post.
sometimes disabling autotuning can help, run the following:
netsh interface tcp set global autotuninglevel=disabled
netsh interface tcp set global rss=disabled

Saturday, 29 March 2008 16:45:19 (GMT Standard Time, UTC+00:00)  #    Comments [0]  

# Thursday, 31 January 2008
LoginView does not execute <% %> expressions
... unless you DataBind() the LoginView first of all.  just posting this in case i forget!


Thursday, 31 January 2008 16:59:39 (GMT Standard Time, UTC+00:00)  #    Comments [0]  

Confirm prompt for DropDownList
this wasn't very obvious to work out, and i couldn't find a decent solution online, so i came up with this.
this.DropDownList1.Attributes.Add("onchange", "if(!confirm('Are you sure you want to delete this item?')) return;");
This works with .Net 2 and 3 and 3.5, but may break with future versions if .Net changes the javascript code for AutoPostBack drop down lists.  The reason it works now is because .Net adds the custom 'onchange' attribute before it's on doPostBack() function call.  So if we return from the confirm prompt, the form will not submit. 


Thursday, 31 January 2008 16:32:13 (GMT Standard Time, UTC+00:00)  #    Comments [0]  .Net General | Asp.Net

# Tuesday, 29 January 2008
Update All Fields in Word Documents
great post by Curtis Keisler explaining how to do this: http://www.devblog.com/2007/12/update-all-fields-in-word-document.html


Tuesday, 29 January 2008 12:15:35 (GMT Standard Time, UTC+00:00)  #    Comments [1]