Installing SQL Server 2008 Express

by Codewiz51 August 31, 2010 21:35

I work with multiple database servers: Oracle, SQL Server and MySQL.  I like to keep copies of the free versions, Oracle XE, SQL Server 2008 Express, SQL Server 2005 Express and MySQL on seperate VMWare machines at home for testing and experimentation.  You learn quickly that installed database servers on your base machine at home can get complicated (and may also slow you machine down if mutiple instances of servers are running on your desktop at home).  VMWare may seem a little expensive, but keeping your base machine clean is well worth the $200 cost.

I recently installed the full version of SQL Server 2008 Express edition and I discovered something that is not really obvious in the documentation.  You need to set up a service account to run your SQL Server services before you begin installation.  Setting this account up before you install, will ensure that your installation goes smoothly.  I've now had to uninstall and reinstall SQL Server 2008 twice on two different VMWare machines -- slow learner am I. Embarassed

Stuff that makes your head explode...

by Codewiz51 August 30, 2010 19:52

I've been experimenting with jQuery and AJAX in VS 2008.  Today, I ran into an issue that nearly made my head explode.  I have some javascript code that I use to detect if a user has a popup blocker installed.  This is an internal application and it makes use of popups to deliver information.  The code isn't strictly correct, but it works with the various versions of IE that we need to support.

Under the head tag, the following code block tests if a window can be opened from code:

<script type="text/JavaScript" language="JavaScript">
    var mine = window.open('', '', 'width=1,height=1,left=0,top=0,scrollbars=no');
    if (mine) {
        var popUpsBlocked = false;
        mine.close();
    }
    else
        var popUpsBlocked = true;
</script>

Just after the </body> tag the following code alerts the user to the state of their pop up blocker:

<script type="text/JavaScript" language="JavaScript">
    if (popUpsBlocked)
        alert('Please disable popup blocker software when using this web site.');
    else
        alert('No popup blocker.');
</script>

I added a script tag to the <head> tag of the html to load jQuery:


<script src="scripts/jquery-1.4.1.min.js" type="text/javascript"/>

Low and behold, my javascript code was borked with an exception that the var popUpsBlocked was not declared!

After much experimenting, I was able to add popUpsBlocked as a global variable as follows:

<script type="text/JavaScript" language="JavaScript">
    var popUpsBlocked = false;
</script>

The finished aspx page is coded as follows:

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>

<script src="scripts/jquery-1.4.1.min.js" type="text/javascript"/>

<script type="text/JavaScript" language="JavaScript">
    var popUpsBlocked = false;
</script>
 
<script type="text/JavaScript" language="JavaScript">
    var mine = window.open('', '', 'width=1,height=1,left=0,top=0,scrollbars=no');
    if (mine) {
        popUpsBlocked = false;
        mine.close();
    }
    else
        popUpsBlocked = true;
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
<script type="text/JavaScript" language="JavaScript">
    if (popUpsBlocked)
        alert('Please disable popup blocker software when using this web site.');
    else
        alert('No popup blocker.');
</script>       
</html>

 

I guess the moral is, be prepared to experience something that frustrates the heck out of you everday. Cool

Oracle Database Frustrations

by Codewiz51 August 29, 2010 20:45

I've been working on a project, utilizing Oracle XE in a VMWare machine for database development.  The project has been rocking along properly, without hitches or hiccups on Oracle XE.  I began to move the system over to a full Oracle 10g database server on Friday.

My scripts ran without error on the staging server, and I had my databases built in maybe two hours.  I copied over the aspx pages and cs files and the application was up in another hour after I tweaked some code.

Then my troubles started as soon as I began unit testing.  My Oracle queries were taking forever to execute!  I mean forever.  Queries utilizing the same data on the Oracle XE server were completing in 3 to 4 seconds.  The same query on the 10g staging server was taking almost 30 minutes.  Absolutely amazing.

I ran the Oracle ODT query analyzer that ships with the 11h client and was hit with a "You must have a valid license... yakkity yakiity whatever message."  All I knew was we didn't have the license.  So now, I get to explain to my boss that something that was supposed to happen quickly is not going to happen quickly unless some sort of solution from heaven falls to earth and lands on my server.

I normally like working with Oracle databases and programming in PL/SQL. But, events like what happened Friday definitely dampen my enthusiasm. Embarassed

New Release of DCDFlib

by Codewiz51 July 07, 2010 21:51

Release 1.6.9.11 of DCDFlib.  Minor clean up.  I am a little over the halfway mark for removing labels and general code modernization.

Implementing the IComparer interface

by Codewiz51 June 13, 2010 12:29

As Windows software developers, we have a tendency to focus on user interface elements, sometimes to the exclusion of program efficiency and performance.

Recently, I was performing a code review on a program that was keeping a list of class instances.  I worked out an example file and profiled the program execution.  My example took nearly 45 seconds to complete!  Ouch!

The developer was using a list of class instances to store data values (much like a multidimensional array).  I won't get into the debate of multi-dimensional arrays versus a list of class instances, it doesn't really matter.  What does matter is the developer needed to find a particular class instance in the list of classes (often).  The developer was using the following psuedo code:


bool FindInstance(CClassInstance CI)
{
    foreach (CClassIntance t in ListofInstances)
    {
        if (t.Property1 == CI.Property1)
            return true;
        else
            return false;
           
    }
}


While there is nothing programmatically wrong with this code, it was the largest consumer of CPU cycles when I ran a performance profile in VS 2008.  The routine was called a lot, and it looped a lot.  Neither is particularly efficent.

Had the developer implemented the IComparer interface, his code would have performed much more efficiently.  The list could have been sorted once, and BinarySearch could had been used to determine if the instance existed in the list:
 

public class CClassInstanceComparer : IComparer<CClassInstance>
{
    public int Compare(CClassInstance a, CClassInstance b)
    {
        if (a.Property1 == b.Property1)
            return 0;
        elseif (a.Property1 < b.Property1)
            return -1;
        elseif (a.Property1 > b.Property1)
            return 1;
    }
}

// In the calling code:
// ....
// Implement the following, rather than calling FindInstance

CClassInstanceComparer_compare = new CClassInstanceComparer();
ListofInstances.Sort(_compare);

// Do some more stuff
// ....
// Finally, see if an instance exists.

if (0 == ListofInstances.BinarySearch(_instanceToSearch, _compare))
{

    // Do something

}
else
{

    // Do something else

}


The sort and binary search code executed a little over 100 times faster, causing a complex calculation to improve some 45 seconds to less than .5 seconds.  (In this case, the list of class instances was over 10,000, which caused lengthy linear searches to occur.)

The moral of this story is it pays to know the details of .Net.  Spend some time and learn the simple stuff.

Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen | Modified by Mooglegiant


Disclaimer

This blog represents my personal hobby, observations and views. It does not represent the views of my employer, clients, especially my wife, children, in-laws, clergy, the dog, the cats or my daughter's horse. In fact, I am not even sure it represents my views when I take the time to reread postings.

All comments are moderated for content.

© Copyright 2008-2010