Add/Remove buttons not showing

I'm sure I'm not the first person who's done it - create an MSI, install it, works great. Uninstall it, falls over and can't get rid of the thing.

This pretty much leaves you to remove things the old fashion way. The only downside is that you still have the thing sitting in your Add/Remove programs list, which you can't delete.

This is where you have to fire up regedit.exe, and navigate to

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{your program}

and blow it away from there. That all works fine if you didn't use windows installer. But if you did, you'll check add/remove programs and see that not only is it still in there, it now doesn't have any change/remove buttons.

Missed something. Back in the registry, navigate:

HKEY_CLASSES_ROOT\Installer\Products\{your product}

and get rid of it there too.

Installation / uninstallation could be regarded as the most important part of your program. Make sure you spend a decent amount of time testing & ensuring that your application installs and uninstalls correctly, otherwise users will neither have the inclination nor the ability to install future versions.

SQL Server GO statements

Why don't go statements work within a SQL script I run from my .net program?

This is simply because "go" isn't SQL. It's only able to be interpreted by management studio, so when you run it from your application, it's going to throw you errors saying it's invalid SQL (and rightfully so).

But there are times when you just need it right? I mean, say you've written an enormous SQL script to upgrade a database. You've spent days on the thing, and it runs perfectly within Management studio with full error checking etc.

So you embed the script within your application, read it into an SqlCommand(), and suddenly you get heaps of errors. Frustrating huh? Even if you take out all of your "go" statements, the script is then broken, because you create a table at the top of the script, and then try to insert values into it at the bottom where it still hasn't been created!

But there is a simple way around this.

The first thing you need to do is do a replace-all in your Sql Script. Open your script up and replace "go" wtih "go--runtoline". Make sure you have 'match whole word' on, otherwise you'll mess up a heap of stuff. When you run the script it should run exactly the same as before you did the replace.

Next thing is in your code, you want to split up the script into a set of sub routines as such:

private void Execute(string sql)

{

    string[] queries = Regex.Split(sql, "go--runtoline");

    using (SqlConnection conn = new SqlConnection("connection string"))

    {

        conn.Open();

 

        SqlCommand com = new SqlCommand("begin transaction", conn);

        com.ExecuteNonQuery();

 

        foreach (string queryChunk in queries)

        {

            com.CommandText = queryChunk;

 

            try { com.ExecuteNonQuery(); }

            catch (Exception e)

            {

                com.CommandText = "rollback transaction";

                com.ExecuteNonQuery();

                throw e;

            }

            finally { conn.Close(); }

        }

        com.CommandText = "commit transaction";

        com.ExecuteNonQuery();

        conn.Close();

    }

}

And that should give you the same behaviour as running your "go" based script in sql server.

«November»
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678