Monday, 31 May 2004
Installing Windows XP on a Shuttle ST61G4 with SATA hard disk (no floppy drive)
This is my first post on my new PC, a Shuttle ST61G4. 3Ghz P4, 1Gb ddr 400 ram, 160Gb SATA hard disk. It feels like a small miracle that it's working, that's how difficult it was for me to install Windows XP on the SATA hard disk.
Partly it was due to me never having used SATA before, and not realising that Windows XP doesn't bundle the SATA drivers I need for the Silican SATA Controller (Si3112r) that is part of the Shuttle mainboard. Also, the most annoying part was that Windows setup only allows you to specify additional drivers from a floppy disk. The shuttle, being a modern compact PC, doesn't come with a floppy of course, so i was stumped. I really didn't want to pull out the old floppy drive from my other PC, but i was forced to in the end.
There is a way to slipstream the drivers into the Windows setup files and then burn them back to a CD, but this sounded way too complicated for me.
The CD with the shuttle mainboard drivers had instructions for how to create the required floppy for a Windows install, and this worked OK, when i finally figured out how to get the Shuttle to recognise the floppy drive. It took a while to find the plug in the motherboard for the floppy, at the back around the side under the power supply. Then i had to enable Floppy Disk 1 in the bios as a 1.44mb drive. Still didn't work, so i enabled Boot up Floppy Seek. Still didn't work, and i finally found out that another setting 'FDC Controller' was disabled, which i needed to enable. Then the floppy drive worked, and it went without hitch from there on in. you also need to enable the Raid controller in the bios.
When the computer boots, the SATA controller part still says "Drive 1542311Mb - Drive not found" or something, although this doesn't seem to matter since windows is able to recognise it.
I found all this out the hard way, and i looked for a long time online to find an easier way of doing it, or clear instructions detailing every step necessary, and i found a FAQ page on shuttle.com (afterwards!) which details the process very well, its a shame it was so hard to find through the shuttle web site.
But my shuttle is fast and very lovely, and it is the quietest thing i have never heard. I can't figure out why they make you press the reset button with a pen though, its so tiny. In the end, i love it.
Monday, 31 May 2004 00:20:44 (GMT Daylight Time, UTC+01:00) General
Monday, 24 May 2004
Environment.SpecialFolder enumeration not showing up in Visual Studio Intellisense
I was using an OpenFileDialog and i wanted it to open at the My
Pictures folder for the current user. So i looked up the msdn
docs for how to locate this folder, and i come across the
Environment.SpecialFolder enumeration, which has an entry for
MyPictures. Great, my code then was:
this.openFileDialog1.InitialDirectory = Environment.SpecialFolder.MyPictures;
but this didn't compile, and it didn't show up
in Intellisense. I read a few examples online which used the
this.openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
and it worked, although it still didn't show up in
Intellisense. you'd think MS would at least explain this in the
Monday, 24 May 2004 12:34:15 (GMT Daylight Time, UTC+01:00) .Net Windows Forms
Saturday, 17 April 2004
Use a HOSTS file to block banner ads
You can use the HOSTS file in Windows to prevent banners from displaying in web pages. It is usually in c:\windows\system32\drivers\etc. Note that it has no file extension. There are a few good sample files online that contain thousands of known advertisers. I use http://everythingisnt.com/Hosts as a reference. If that link is down, use my mirror copy (29 k). The way it works is by redirecting the url (e.g. ad.doubleclick.net) to your own computer, instead of the proper doubleclick.net server. Your local web server (if you have one) won't contain any of banner images or pages requested and you see a 404 page not found in the browser in place of the banner image / web page.
Saturday, 17 April 2004 17:53:23 (GMT Daylight Time, UTC+01:00) General
Saturday, 03 April 2004
ADO.NET parameter quirks with ODBC and OleDb
The OleDb Provider
If anyone is using the Oledb provider with .Net, when you are adding parameters to an OleDbCommand in code, make sure you add them in the order that they belong in the sql string.
For example, if your sql string is:
"insert into table1 (username, password) values(?,?)"
and you have parameters added to the command (usually done through a configure OleDbDataAdapter wizard), called "@Username" and "@Password". Your code must add the parameters in the correct order as follows:
this.oledbCommand1.Parameters("@Username").Value = username;
this.oledbCommand1.Parameters("@Password").Value = password;
If you don't do it this way, you may get a jet error: "No value given for one or more required parameters.".
This quirk does not apply for the Sql provider in ADO.NET, because you can name the parameters in the sql string, e.g.
"insert into table1 (username, password) values(@Username, @Password)"
The ODBC Provider
If you're using the ODBC provider with .NET (probably for MySQL), there is one oddity that you should know about too. In sql strings for odbcCommand objects, you can't use the @ParamName syntax. You have to use question marks as placeholders for the parameters as follows:
Saturday, 03 April 2004 18:07:08 (GMT Daylight Time, UTC+01:00) Database
"insert into table1 (username, password) values(?,?)"
Similarly, you have to add the parameters in the right order.
Thursday, 01 April 2004
Working around DVD install problems. Use Xcopy instead...
when i was building my computer, i got a cheap DVD drive, and i'm paying for it now with trouble installing any of the software that came on DVDs with my MSDN subscription. I tried installing Windows Server 2003 from the DVD by booting straight from the CD but it failed at different stages, saying file not found, or corrupted files etc. I'm convinced its because of the quality of the dvd drive. To be safe, I now copy all the files to the hard drive and then install from there. Even copying the files to the harddisk through Windows was not trivial as ms point out in http://support.microsoft.com/default.aspx?scid=kb;en-us;Q318945, they recommend using the xcopy command to verify that the files are copied correctly. The copy speed with xcopy was several times faster than using windows explorer, I have no idea why, but i always do it that way now. The syntax is:
xcopy <source> <destination> /V /H /Y /E
e.g. (from the command prompt. Start > Run > cmd.exe)
xcopy E:\VS2003\ C:\Local\VS2003 /V /H /Y /E
The switches mean:
Thursday, 01 April 2004 15:25:50 (GMT Daylight Time, UTC+01:00) General
/V = verify
/H = hidden files
/E = sub folder including empty folders
/Y = suppresses prompting to overwrite
Friday, 26 March 2004
Micorosft Empower Program, the motivation behind it...
My application to join the MS Empower Program for ISVs was accepted this week. The first thing I did was go straight to the MSDN download section and drool over all the software now available to me to download. (Shame I'm on 56k... oh eircom get your act together and deliver broadband soon, it's not like I live in the sticks or anything <moan moan>)
For a €375 subscription fee I get the equivalent of €30k worth of software, of which I will realisitically only use a few thousands worth, but still, how bad. There are a few costs associated with it, like a software verification test, digital ID from Verisign etc. but it's still a great deal, and actually the cheapest way for me to start using Visual Studio 2003 architect.
I sat today wondering why MS are acting so desperate to get ISVs like me to write software for .Net in particular. Then it struck me... (a rare moment of mental clarity), and I remembered back to what a man was saying at a Longhorn conference I was at earlier in the year. He said that Windows Longhorn will run with 2 kernels, one for Win32 apps and a new kernel for apps written in .Net, i.e. managed code. This is obviously great for backwards compatibility, with the advantages being given to new applications with the new kernel. BUT... what if .Net apps don't become mainstream for 5 or more years?! the new kernel will be more or less unused and we might as well be running a souped up XP pro instead. Avalon, the new user interface, will also only work with .Net apps (.Net 2.0 at that), and other apps will look the same as XP. It is no wonder MS are not giving a solid release date for Longhorn, since I reckon it depends on the take-up of .Net software. If it is great, they will push to release longhorn early to give users the advantages of running .Net apps on a managed operating system. But if it is slow, they will throw more and more resources to the developers and software companies in programs like Empower for ISVs until the knock-on effect of that is to put a whole lot more .Net software in to the marketplace until .Net becomes the standard.
Here we are 2 or 3 years into the launch of .Net and most people around here still think it's bleeding edge technology if they have heard of it all. (Yes there is a modern side to Ireland, but a lot of it is still running Windows 95, that's the reality of the environment we are building software for).
Something about knowing that my apps will one day execute in a managed Kernel in Longhorn really gets me going :) but i think it might be longer than MS think before it becomes the norm.
Friday, 26 March 2004 23:57:16 (GMT Standard Time, UTC+00:00) General
Tuesday, 16 March 2004
Howto: use MySql with .Net
MySQL is a great alternative to SQL Server because it is open source
and nearly has the performance to rival SQL Server. Applications using
Microsoft Access databases can suffer seriously if the transaction load
is anything above minimal. This article is my collection of
instructions and tips for getting up and running with MySQL and .NET.
- Download & Install MySQL 4.0 (16 Mb)
- Download & Install ODBC.NET Data Provider (800 k)
- Download & Install MyODBC 2.5 (1.5 Mb)
Note: the newer versions do not work with .NET at time of writing
- Optional: Download & Install DBManager, GUI for MySQL tables, highly recommended (3 Mb)
- Make sure the MySQL service is running in Windows.
- Load up the WinMySQLAdmin.exe tool in the bin folder of your
MySQL install. This program controls the MySQL server. Feel free to
customise any settings you wish, e.g. change the Server Name, Port
Number, username & password etc.
- Load up DBManager and connect to the Server. The default user
is root with a blank password. You can create your own users or keep
using the root. Create a test database and then right-click the
'Tables' node under the database you just created. Use the 'Table
Editor' to define the fields for the table. Click the 'Save' icon to
save your changes. Users from MS Access backgrounds may want to read below.
To connect to the database through .NET code:
Add a reference to Microsoft.Data.Odbc.dll, this should be in 'C:\Program Files\Microsoft.NET\Odbc.Net'
string sql = "select * from table1 where ShortName = ?";
// declare an OdbcCommand object with a new OdbcConnection
OdbcCommand command = new OdbcCommand(sql, new OdbcConnection(connString));
// add a paramter to the command corresponding to the ? in the sql statement
OdbcParameter dbParam = new OdbcParameter('ShortName", OdbcType.VarChar, 50);
dbParam.Value = "bob";
DataSet ds = new DataSet();
OdbcDataAdapter dba = new OdbcDataAdapter();
dba.SelectCommand = command;
Unfortunately, MS never provided OdbcDataAdapter & OdbcCommand
GUI support for Visual Studio so you have to do all that manually, as
in the code above. However, there are commercial components that solve
The 'System Error' ODBC message
If you get a
'System Error' message thrown in your code using MySQL, with no useful
information, you need to catch the line of code causing the error and
throw the exception explicitly (i have no idea why, but MS have a kb article about it).
Note on DBManager Queries
This version of MySQL
doesn't support Stored Procedures, but you can still save queries to
the database. Click the 'Create new query' button in DBManager and
enter the SQL you want. There is a query designer but the intellisense
doesn't work well and it can be annoying to use. Save the query and it
appears as an extra tab after 'DataSheet' in the lower right corner.
When you close DBManager, next time you open it, that tab won't be
there and it will look like the query was only temporary. They are
actually stored permanently, and accessible via the 'Tools' tab on the
lower right of the screen.
Notes on the MySQL field types for anyone from an MS Access background
- MySQL uses the single apostrophe character for quoting values, e.g.
select * from table where name = 'bob'. the double quote character
causes a syntax error.
- there is no 'bool' field type as such, use 'TinyInt' and
change the size to 1 bit, then use 1 to represent true and 0 for false.
- the varchar field type is limited to 255 characters, in MS
Access you would use a Memo to go beyond this. MySQL has the tinytext,
mediumtext and longtext field types to support larger max characters.
- to force the input to match a list of values, e.g. Categories:
Animal / Vegetable / Mineral, use the 'Set' field type, with comma
separated values in single quotes: 'Animal', 'Vegetable', 'Mineral'
- the 'Now()' function is supported in MySQL as a default value
for a DateTime or Date field, but when you enter this in DBManager, the
value appears as 0000-00-00 00:00:00 in the Table Editor, this seems
unusual but the function works as expected.
BTW, if you're looking for .NET web hosts that support MySQL, check out www.webhost.ie
Tuesday, 16 March 2004 23:27:39 (GMT Standard Time, UTC+00:00) Database
Problem setting text for a password asp.net textbox
This short article outlines a quirk of the textbox control in
Asp.Net, when set to password mode. If you try and use
myTextBox.Text = ….; it doesn't happen.
You might want to use something like this if you are presenting
users with the facility to change a password, and you want to give them
the option of changing their password, shown in stars, by simply
deleting the stars and typing in a new one. To accomplish this,
use the following syntax:
myTextBox.Attributes("Value") = someString;
I can't think of a good reason ms built it this way at all. oh for .net 2.0...
Tuesday, 16 March 2004 23:06:12 (GMT Standard Time, UTC+00:00) Asp.Net
Monday, 15 March 2004
Windows Forms DataGrid throwing a null reference exception on DataRowView.CancelEdit()
I encountered a frustrating issue using the Windows forms Datagrid today. This problem was also posted without reply on an ms newsgroup. I'm posting my work around here for the record.
My windows form had a tabcontrol, with 2 tab pages, each with a datagrid, bound to a table in a dataset. The problem occurred when the user switched from the second tab to the first, with the last row of the datagrid being left as a new row with default null values. It was in 'edit mode' usually because the user added a new row, or pressed enter, which automatically places the cursor in another empty new row, with the default values. The exception I got was generated by the framework and not from my code, as follows:
Object reference not set to instance of an object, at:
System.Windows.Forms.DataGrid.OnLeave_Grid() at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
The exception is interesting in that the CurrencyManager kicks in when the focus of the DataGrid has left, and cancels the cell currently being edited.
I tried several solutions, and eventually worked around the problem by forcing the user to click a button to switch from one tab to the other (I hid the tab change buttons off the screen), and then disabling whichever grid wasn't being used after the button was pressed. This seemed to change the way the DataGrid cancelled the edit of the last row, and the exception doesn't happen now.
It's not an elegant solution, so I'm open to suggestions. I do think the datagrid should be able to execute CancelCurrentEdit without throwing exceptions, and I would be interested to understand why it happens. I guess it will be fixed in .Net version 2.
Monday, 15 March 2004 19:12:33 (GMT Standard Time, UTC+00:00) .Net Windows Forms
Saturday, 13 March 2004
Howto: configure a Psion Series 5 for internet access with a Nokia 6610 (GPRS)
This took ages to figure out, and plenty of experimenting with different settings, so hopefully this might save someone else the hastle of having to spend half a day to get their Psion 5 (not MX) connected to the net with a Nokia 6610. I would say it would work with similar settings on other GPRS phones.
The internet settings are for the O2 network in Ireland and will need adjustments for a different network.
Saturday, 13 March 2004 23:10:23 (GMT Standard Time, UTC+00:00) General
- install Psion Series 5 Message Suite version 1.52.
- Create a new modem called nokia 6610:
fax class auto,
init string: ATZ
flow control: hardware (RTS/CTS)
- Create new Internet Service called GPRS with the following settings.
connection type: dialup
uncheck smart dialing
standard dial-up number: *99#
manual login unchecked
addresses: get IP from server. get dns address from server unchecked.
primary dns address: 18.104.22.168
secondary dns address: 22.214.171.124
login: use login script checked. default 8 bit no partity 1 stop bit,
delete all content of login script text box, leave blank.
advanced: enable PPP extensions checked. allow plain text authentication checked.
- On the psion, set Remote Link to Infrared 57600.
- Get the GPRS settings for your phone from your network. O2 will send those details to your phone if you request it from http://www1.o2.ie/CM/getcontent/0,1177,txt_html_OTA_Home,00.html. Save these details to your phone.
- Activate Infrared on the phone. Connectivity > Infrared.
- Point the Infrared port of the phone thin black band on top of phone) to the Infrared port on the psion (1cm band on back of psion) a few inches away.