jump to navigation

SQL Server 2008: Saving Changes Is Not Permitted 15 October 2008

Posted by thegotoguy in Software Development.
Tags: , , , , , ,
add a comment

I came across this a couple weeks ago but was in such a rush to get teh work done that never got around to posting about it. Anyway, I ran into it again today which reminded me to make a post about it.

Basically, you recieve the following message when you try to save changes you’ve made to a table in the SQL Server Management Studio table designer:

This is actually caused by a setting in the SQL Server Management Studio which you can easily turn off by going to Tools –> Options and deselecting the option indicated below:

LUA Scripting With .NET 19 September 2008

Posted by thegotoguy in Software Development.
Tags: , , , ,
add a comment

I’ve been keen to learn more about LUA scripting for some time now. I started last year but then got side tracked by more pressing matters and it was put aside for the time being.

Anyway, my interest in it has been re-ignited so I browsed around for more info. First stop is the home of LUA – lua.org. It is undoubtedly the best place to start.

Next stop is lua-users for some user made addons – IDEs, wrappers, documentation, etc. That’s where I found LuaInterface, a .NET/CLR wrapper for the LUA library! Joy of joys!

During my search I came across this fantastic little blog post about using LuaInterface to implement LUA scripts in C# code.

I might write my own little tutorial on the subject at a later date – time permitting of course – so keep an eye out. In the meantime, please let me know if you come across any other cool resources for LUA, particularly if it involves .NET.

Take care,
TheGoToGuy

VB.NET/C# Converter 17 September 2008

Posted by thegotoguy in Software Development.
Tags: , , ,
add a comment

While I program mostly in VB.NET at work, I prefer C# more and make use of it in all my personal projects. Now this isn’t a post about VB.NET vs. C#, there are enough of those on the web, and I personally feel that both, like all things, have their own pros and cons.

But I do like to provide code samples in both languages in my blog and let’s face it, I would be an idiot if I spent so much time retyping code in another language. Thankfully though, there is a way to just copy, paste, convert. Here is one.

Of course if you actually wanted to do it, you probably would have googled it first and found the site like that – it is the first site in the list – but if you somehow missed it and all the others and found yourself here, then today is your lucky day.

Take care,
TheGoToGuy

Currency Converter Web Service 17 September 2008

Posted by thegotoguy in Software Development.
Tags: , , , , ,
2 comments

Keen to create my own currency converter I went in search of a web service that would provide the exchange rates at fairly frequent intervals. It was in this search I stumbled upon this.

It seems a bit slow, but that could just be my 3rd world internet connection. It is however free and incredibly easy to use. For example, to see how many South African Rands are needed for 1 Australian dollar simply do this (after creating the web reference obviously):

C#

wsCurrencyConverter.CurrencyConvertor converter =

new wsCurrencyConverter.CurrencyConvertor();
double rate = converter.ConversionRate(wsCurrencyConverter.Currency.AUD, wsCurrencyConverter.Currency.ZAR);
converter.Dispose();

 
VB.NET

 

Dim converter As New wsCurrencyConverter.CurrencyConvertor()
Dim rate As Double = converter.ConversionRate(wsCurrencyConverter.Currency.AUD, wsCurrencyConverter.Currency.ZAR)
converter.Dispose()

Ok, so I’m not really sure how often it updates the values, I’ll check that over the next couple of days probably. If you know of any other freely available web services that provide the same sorta thing, please let me know.

Hope you found this useful.

Take care,
TheGoToGuy

Extracting An MSI Install Package 10 September 2008

Posted by thegotoguy in General.
Tags: , , , , , ,
add a comment

On a few occasions I’ve had a need to extract the contents of an MSI install package without actually running the install. I figured others might need to do the same so I decided to make this post.

Simply run the following from the command prompt, replacing the placeholders with the file and destination:

msiexec /a <msipath> /qn TARGETDIR=<destinationpath>

Easy isn’t it?

Take care,
TheGoToGuy

JRock – You’ll Be Surprised 9 September 2008

Posted by thegotoguy in Music.
Tags: , , , , , , , , , , ,
add a comment

I’ve  been wanting to make this post for some time so here it is. I’ve got a somewhat peculiar taste in music. In fact six months ago I went through a classic and opera phase. Actually I lie, I’m stilling going through it, and it wasn’t really a phase.

Anyway, about two months ago I made an amazing discovery…Asian Kung-fu Generation. They’re a Japanese rock band and I can honestly say they are one of the best bands I’ve ever heard. Despite not understanding anything they say I can’t stop listening to them. The music is awesome and the production is superb.

Shortly after, I decided to find some other JRock bands I might like and I came upon a few more that I liked alot, namely The Pillows, Bump of Chicken, Mr. Children, Ellegarden and Straightener. They vary in styles and some, like Bump of Chicken even do different songs in completely different styles – think reggae for one song then punk rock for another. Most of them have influences from famous English-speaking bands like The Beetles, The Beach Boys and even Blink 182.

If you want to hear something different and looking for a little surprise, take a listen to some JRock, you won’t be disappointed.

Take care,
TheGoToGuy

Bahrain World Trade Centre 8 September 2008

Posted by thegotoguy in Science & Technology.
Tags: , , ,
add a comment

I saw a show called Megastructures this weekend which as you might have guessed showcases really big structures. This episode focused on the Bahrain World Trade Centre located in Manama, the capital of Bahrain.

I found it a particularly fascinating structure for several reasons. Firstly, given the worlds current frenzy over all things green, enviromentally friendly and efficient the buildings claim to fame seems fitting. Secondly it was designed by a South African. Thirdly, it’s simply a stunning building.

Let me start off with the buildings claim to fame then. That would be the three giant wind turbines attached to bridges linking the two fifty storey skyscapers. It makes it the first building in the world to incorporate wind turbines into it’s design. These turbines are expected to deliver up to 15% of the buildings power needs.

The architect that designed it was, like I mentioned earlier, a South African by the name of Shaun Killa. And it’s times like these that make me proud to be South African. He’s an avid yachtsman and it was this hobby that inspired the design of the BWTC.

It really is an astonishing accomplishment and a testament to what can be done when one puts their mind to something. It’s also ironic that a building of this type was built where it was. Who would have thought that a building designed to be energy efficient would be built in a part of the world that thrives on the consumption of energy.

Take care,
TheGoToGuy

Get The Value Of An XML Attribute In SQL 5 September 2008

Posted by thegotoguy in Software Development.
Tags: , , , , , , ,
add a comment

A collegue of mine was battling to get the value of an attribute out of some XML stored in our database and came to me for some help. I figured others might need the same help so decided to blog it here.

Say you’ve got a table called “testtable” that contains an xml column called “xmlcol” with the following xml:

<Root>
   <Node1 Attribute1=”One” Attribute2=”Two”/>
</Root>

 

Now to get the value of Attribute2 simply use something like this:

select

xmlcol.query(‘data(/Root/Node1/@Attribute2)’)
from testtable

This will return “Two”. Now that wasn’t too hard now was it?

Take care,
TheGoToGuy

Detailed Errors On IIS7 5 September 2008

Posted by thegotoguy in Software Development.
Tags: , , , , , , , ,
add a comment

A friend of mine is a web developer and recently upgraded some of his company’s infrastructure which included an upgrade of the webserver to Windows Server 2008.

Server 2008 comes with IIS7 and my friend was battling to get it to display detailed errors, particularly with his classic ASP pages. It kept displaying the not-so-helpful “500 – Internal Server Error ” message. Now he had already set the classic ASP debugging options correctly so it must have been something else he missed. So I had a crack at the server myself and managed to figure out which setting he was missing.

It’s worth noting the same steps can be used on a Vista machine as well which is what I’ll be using to show you the way so to speak.

Open up computer/server management and locate the IIS Manager:

Next look to the right and select the instance you want to make the change on and open up the “Error Pages” feature to the right of the that:

You should see something like the following. Hit the “Edit Feature Settings…” option in the action pane to the right of that:

Select “Detailed Errors” and click “OK”:

And that’s it. I did some searching of the net to see if anyone else had had this problem, and strangely I only came across one forum post asking about it. The answer that was given was also brilliant. It essentially performs the same function I did but it’s much quicker and possibly simpler. Simply open up the command prompt and run this:

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpErrors -errorMode:Detailed  

Unfortunately I can’t find the post now, but if I do stumble upon the forum again I’ll update this post with it’s details.

Take care,
TheGoToGuy

SQL Compatible Date With .NET 5 September 2008

Posted by thegotoguy in Software Development.
Tags: , , , , , ,
add a comment

I’ve been dealing with SQL Server for quite a while now. I’ve worked with SQL Server 2000, 2005 and more recently 2008. The one annoyance that has persisted throughout is date formats, or the management thereof.

Now granted this isn’t really a SQL problem because SQL does offer numerous ways to input and output dates. It was always more of a programming issue, mostly for input. Say you wanted to enter a date like the 6th of June, 2008. That would look something like this: 06/06/2008. So which is the day and which is the month? This would come down to your setup. This can be a problem when developing for a widely distributed application where the setup and enviroment can vary greatly and they arent under your control.

That’s why I came up with a .NET function that formats a given date into a standard, universal SQL date format – yyyymmdd. So no matter what the setup or enviromental settings are it will always be used correctly.

VB.NET:

 

Public Shared Function FormatSqlCompatibleDate(ByVal WholeDate As DateTime) As String
Dim DateBuffer As String
Dim Day As String = WholeDate.Day.ToString
Dim Month As String = WholeDate.Month.ToString
Dim Year As String = WholeDate.Year.ToString

If Day.Length = 1 Then
Day = “0” + Day
End If

If Month.Length = 1 Then
Month = “0” + Month
End If

DateBuffer = Year + Month + Day 

Return DateBuffer
End Function

C#:

 

public static string FormatSqlCompatibleDate(DateTime WholeDate)
{
string DateBuffer;
string Day = WholeDate.Day.ToString;
string Month = WholeDate.Month.ToString;
string Year = WholeDate.Year.ToString; 

if (Day.Length == 1)
{
Day =
“0” + Day;
} 

if (Month.Length == 1)
{
Month =
“0” + Month;
}

DateBuffer = Year + Month + Day; 

return DateBuffer;
}

Hope you found this useful.

Take care,
TheGoToGuy