Monday, September 10, 2007

ASP.NET and MS SQL Server 2005 - Bit / Boolean Type

Ok, I'm not a hardcore programmer, so today I found something that was quite wierd to me at least.

Now I have MS SQL Server 2005 as my backend database. I created a simple type with a couple fields, one being of type "bit", which can hold the values of 1, 0, or null. Since there isn't any boolean type, then this is what should be used for true and false data.

Now, I am programming in ASP.NET which communicates with the database. I was trying to do a simple INSERT command into this table and for awhile I couldn't figure out why it wasn't writing into it.

For example my SQL statement in ASP.NET could be like this:
Ex1. INSERT table1 (x1, x2, y1, y2) VALUES ('hello', 'there', True, False);

Or say I have a couple radio buttons R1 and R2 somewhere:
Ex2. INSERT table1 (x1, x2, y1, y2) VALUES ('good', 'bye', R1.Checked, R2.Checked);

In SQL Server: x1 and x2 are nchar(10), y1 and y2 are bit

Both statements did not work. If I actual values like 1 or 0, those will work.
Ex3. INSERT table1 (x1, x2, y1, y2) VALUES ('good', 'bye', 1, 0);

The only way to get Ex1 and Ex2 to work is to put bound the True or False by single quotes like a string.
Ex4. INSERT table1 (x1, x2, y1, y2) VALUES ('hello', 'there', 'True', 'False');

To me that is very confusing. But that's how SQL Server takes it.

Dreamweaver - Centering Layouts

This is quite easy to do, but was hard to find out how. If you want your website to always be centered no matter what monitored is being used. Do the following:

1. Make a new table.
[Rows = 1, Columns = 1, Width = 100%, Cell Padding = 0, Cell Spacing = 0, Border = 0]

2. Check inside the table and set: Horizontal align to "center", Verticle align to "middle"

3. Now make another table of any size inside the one you just made and it will always be centered.

MS SQL - Reseting IDENTITY value

If you want to reset your identity field to a certain number, use the following statement:

DBCC CHECKIDENT ('tablename', RESEED, new identity value)

Saturday, September 8, 2007

Viewing .aspx pages in IIS 6 using ASP.NET

Ok, this was super annoying, and it showed me that I don't know jack shit about setting up ASP.NET on IIS to work properly.

The problem I was having was trying to connect to MS SQL Server 2005 using ASP.NET. This did not work as I was getting HTTP Error Code 403. This pretty much means that you lack the permission to access whatever you are trying to access. In this case, I had created an .aspx file that will access SQL Server.

So after fiddling around for like an hour I tried accessing .aspx files in IIS first. Sure enough, I got an error. This time a bit more specific. HTTP Error 403.1 - Forbidden: Execute access is denied. After another hour of searching for an answer as to why my asp.net pages won't display, I finally found the answer, which made me feel really stupid.

In anycase, ASP.NET pages are a scripting language, they run code in the background that "talks" to the backend servers. Now, by default, all websites created in IIS having the scripting permissions taken off for security purposes. Well, that's the problem right there. Turn this option on and you are set.

Go to "Properties" of the website in question, click on the "Home Directory" tab, and change the option "Execute permissions" to "Scripts only" or "Scripts and Executables".

What a waste of time! Definitely feel dumb today.

Monday, September 3, 2007

Rebuilding a Windows 2003 Server Domain Controller from scratch

I couldn't find any advice or help on this particular topic, even though I was pretty sure I knew how to do it. The task was to reinstall a domain controller with it being the only domain controller in the domain. Meaning that when it goes down, there will be no authentication between computers in the network.

The obvious way would be to install another DC so that it can be up while the other is down. But for this situation, another computer is out of the question. So the best way to do this is to completely remove the hard drive and put in a brand new one and install a fresh new version of the OS. After the OS has been installed and updated, perform a dcpromo and make all settings exactly the same as the old DC.

Adobe Flash - Nested communication

When working with Adobe Flash, communicating with various movie clips and swf files can be a pretty stressing.

For nested SWF files, it goes as follows:

1. First SWF (level 0) loads another SWF file into a different level using either loadMovie or loadMovieClip function.

2. The loaded SWF file can then refer to the first SWF by referring to it through "_level0"

For nested movie clips, _root, _parent, this, "instance name of movie clip" can all be used.

_root refers to main timeline
_parent refers to the calling movie clip

Friday, August 31, 2007

Network Detection Methods

Been awhile since my last post, been caught up with a million things here and there.

Recently I have been trying to figure out a way to detect on a network when certain devices are actively connected to the network. Reason for this is when users need to know when a certain devices is sending and receiving data (especially when we are talking about mission-critical devices - such as metal detection, programmable ovens, etc). Nothing is worse when a user "thinks" that the device is sending data only to find out that it didn't and must redo the entire job again. This not only wastes time, but obviously wastes money.

All this is assuming that the device being used has an internal ethernet adapter or is using wireless.

FREEping is a free software that pings any IP and keeps track of it through time. By pinging a certain device at regular intervals you will know whether or not the device is connected or not. Users can simply view the monitor and know right away. I'm sure there is other ping software out there, but this one does the job well enough.

Another solution which is better is to have some sort of LED light on the outside of the device indicating the connection is good, but of course this usually has to be custom implemented if it wasn't already built-in to the device to begin with, which equals more money. But is a better indicator.

Either way, both solutions work fine and I can finally get this little issue out of the way.

Thursday, August 2, 2007

Server Room - Temperature & Humidity

Well, thought I'd talk about this a little bit since this is something that isn't very clear cut. While temperature and humidity levels can vary among all server rooms depending on the number of servers there are, other hardware, type of room, size of room, location of room, etc. Most people aren't sure what the ideal temperature and humidity levels should be to properly cool their equipment.

I can say that from my experience it varies a lot, but there are general guidelines to follow. Most of the IT community (from talking with individuals in the field and through sources on the Internet) agree that the server room should not exceed roughly around 28 degrees Celsius in general. I think that's way too high in my opinion, 28 degrees in a room is pretty warm!

I've had the server room hit 26-27 degrees before and to me it was really warm. APC wrote a white paper to give their general guidelines (http://www.apcmedia.com/salestools/VAVR-5UDSLG_R2_EN.pdf). They say around 22-24 degrees Celsius is adequate with about 35%-50% humidity. Sun Microsystems in a articles (which I cannot find anymore) suggested around 21-23 degree Celsius for temperature.

From what I've read and heard so far and my own opinion on the matter, "normal" server rooms should have temperature of about 19-23 degrees Celsius and about 30%-50% humidity.
Minimum temperature I would say don't go below 16 degrees Celsius and for maximum temperature don't go above 25 degrees Celsius.

Server rooms should always be "cool" and "dry", but not "too cold" or "too dry". Anyway, that's my thoughts on that.