Embed Picasa slideshows into BlogEngine.net

I was having a problem embedding a slide show from Picasa into my BlogEngine.net editor. Basically, the editor kept stripping the embed html.  The trick is to edit \admin\tinyMCE.ascx file.  You need to modify the extended_valid_elements entry. Apparently this is used to define valid html tags for the tinyMCE editor. Here are my additions in red:

extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],

script[charset|defer|language|src|type],code,iframe[src|width|height|frameborder|name|style],

embed[type|src|width|height|flashvars|pluginspage]",

Have fun!

Visual Studio, which version?

What version of Visual Studio is the most current?

Depending on what you are using and which application you are modifing the following are the latest releases of Visual Studio:

  • Visual Studio 6 (Used for the Legacy VB/C++ apps).
    • Latest build is 9782 and this corresponds to Visual Studio 6.0 SP6.
  • Visual Studio 2003
    • Version 7.1.6030. This corresponds to VS2003 SP1 and is a MANDATORY install. If you don't have it install it now.
  • Visual Studio 2005
    • Version 8.0.50727,762 (SP). This corresponds to VS2005 SP1 and is a MANDATORY install. If you don't have it install it now. It can also take over an hour to install.
  • Visual Studio 2008
    • Version 9.0.21022.8 RTM. This corresponds to the RTM release so if you have VS2008 you have this build.
  • Bottlenecks and Monitoring

    I've come across this fab system monitoring tool, Spotlight for Windows

    Spotlight on Windows empowers you to quickly identify and eliminate bottlenecks in the Windows environment

    For a busy IT professional, it is nearly impossible to diagnose, troubleshoot, and resolve every component affecting Windows Operating System (OS) performance using manual methods. Without a clear view of I/O and system activity, you learn of performance issues only after problems erupt.

    With its unique graphical view of the Windows OS internals, Spotlight on Windows will empower the user to rapidly eliminate and identify bottlenecks in the Windows environment. Displaying the real-time flow of data within your Windows OS, Spotlight enables you to quickly identify and resolve performance problems.

    Limitations:

    Spotlight on Windows is unsupported freeware. The license key is provided in the download package and expires one year after installation. To renew, please revisit this website. An activation key will be made available prior to the expiration date of your current key.

    http://www.quest.com/spotlight-on-windows/

    Examples of using System.Data.ParameterDirection with Sql Server

    When working with the SqlCommand you will no doubt have to supply parameters to your command whether it be a Stored Procedure or Text command.  Although not as efficient as an actual Stored Procedure there are some powerful things you can achieve using the System.Data.ParameterDirection, or rather other than just Input.

    The enumeration holds the following values:

    • Input
    • InputOutput
    • Output
    • ReturnValue

    In this article I will give a working example of each, simple but you will see the idea.  At the end I will make a custom object which I will populate using some of these directions.

    For this example I am working with the AdventureWorks Database for Sql Server 2005.

      

    Input

    The most common direction.

                using (System.Data.SqlClient.SqlConnection sc1 =
                    new System.Data.SqlClient.SqlConnection(@"Data Source=REA_ANDREW-PC\SQLEXPRESS;Initial Catalog=AdventureWorks;"+
                        "Integrated Security=True"))
                {
                    sc1.Open();
                    using (System.Data.SqlClient.SqlCommand command1 = new System.Data.SqlClient.SqlCommand())
                    {
                        command1.CommandType = CommandType.Text;
                        command1.Connection = sc1;
                        // DIRECTION :: Input
                        command1.CommandText = "INSERT INTO [Purchasing].[ShipMethod] (Name,ShipBase,ShipRate)"+
                            "VALUES (@Name,@ShipBase,@ShipRate)";
                        //Method 1
                        command1.Parameters.AddWithValue("@Name", "MyShippingMethod");
                        //Method 2
                        System.Data.SqlClient.SqlParameter parameter2 =
                            new System.Data.SqlClient.SqlParameter("@ShipBase", 10.00M);
                        parameter2.Direction = ParameterDirection.Input;
                        command1.Parameters.Add(parameter2);
                        //Method 3 //Deprecated for AddWithValue
                        command1.Parameters.Add("@ShipRate", 10.00M);

                        command1.ExecuteNonQuery();
                    }
                }

     

    Here I have displayed three different syntactical ways of adding parameters to your SqlCommand.  The third and final way is deprectaed and you will see this if you try inside Visual Studio.  Because of this it will not appear inside intellisense.

      

    Output

    The output is going to look like the above example only I will not give it an intial value and simply assign the value inside the command text.

                using (System.Data.SqlClient.SqlConnection sc1 =
                    new System.Data.SqlClient.SqlConnection(@"Data Source=REA_ANDREW-PC\SQLEXPRESS;Initial Catalog=AdventureWorks;"+
                        "Integrated Security=True"))
                {
                    sc1.Open();
                    using (System.Data.SqlClient.SqlCommand command1 = new System.Data.SqlClient.SqlCommand())
                    {
                        command1.CommandType = CommandType.Text;
                        command1.Connection = sc1;
                        // DIRECTION :: Input
                        command1.CommandText = "select @MyParameter = Count(*) FROM [Purchasing].[ShipMethod]";
                        System.Data.SqlClient.SqlParameter paramter1 = command1.Parameters.Add("@MyParameter", SqlDbType.SmallInt);
                        paramter1.Direction = ParameterDirection.Output;
                        command1.ExecuteNonQuery();
                        //The following value is now 6, the number of records inside the table
                        int newValue = (int)paramter1.Value;
                    }
                }

      

    Return Value

    The return value is something which you will return at the end of the statement/s.  For this example I need to create a short stored procedure, again i will simply return the count of records from the table:

    ALTER PROCEDURE CountRows
    ASDeclare @CountR intSELECT @CountR = Count(*) FROM [Purchasing].[ShipMethod]
    RETURN @CountR

    And so the function which will now work with this, and using the ReturnValue direction is as follows:

                using (System.Data.SqlClient.SqlConnection sc1 =
                    new System.Data.SqlClient.SqlConnection(@"Data Source=REA_ANDREW-PC\SQLEXPRESS;Initial Catalog=AdventureWorks;"+
                        "Integrated Security=True"))
                {
                    sc1.Open();
                    using (System.Data.SqlClient.SqlCommand command1 = new System.Data.SqlClient.SqlCommand())
                    {
                        command1.CommandType = CommandType.StoredProcedure;
                        command1.Connection = sc1;
                        // DIRECTION :: Input
                        command1.CommandText = "CountRows";
                        System.Data.SqlClient.SqlParameter paramter1 = command1.Parameters.Add("@CountR", SqlDbType.SmallInt);
                        paramter1.Direction = ParameterDirection.ReturnValue;
                        command1.ExecuteNonQuery();
                        //The following value is now 6, the number of records inside the table
                        int newValue = (int)paramter1.Value;
                    }
                }

     

      

    The simple example object

    I now want to use these counting methods to construct a sample object which will contain simply.

    1. Total Record Count
    2. List<string> of Shipping Names which can be bound to

    This is just for an example, I realise lol that I could simply use the List<string> Count property BUT think of it like this.  What if you wanted to create a paged object so the list actual only contains say ten items because of a page size you set BUT you still have knowledge of the total number of records through the Total Record Count property, from which you could calculate the total number of pages.!! 🙂

     

    The object

    namespace WindowsForm_Examples_NET_2
    {    class SimpleObjectOne
        {
            private int _recordCount;
            private List<string> _shippingNames;

            public List<string> ShippingNames
            {
                get { return _shippingNames; }
                set { _shippingNames = value; }
            }

            public int RecordCount
            {
                get { return _recordCount; }
                set { _recordCount = value; }
            }
            public SimpleObjectOne()
            {
                _shippingNames = new List<string>();
            }
            [System.ComponentModel.DataObjectMethod(
                System.ComponentModel.DataObjectMethodType.Select)]
            public static SimpleObjectOne GetSimpleObjectOne()
            {
                SimpleObjectOne objectOne = new SimpleObjectOne();
                objectOne.Execute();
                return objectOne;
            }

            private void Execute()
            {
                using (System.Data.SqlClient.SqlConnection sc1 =
        new System.Data.SqlClient.SqlConnection(@"Data Source=REA_ANDREW-PC\SQLEXPRESS;Initial Catalog=AdventureWorks;" +
            "Integrated Security=True"))
                {
                    sc1.Open();
                    using (System.Data.SqlClient.SqlCommand command1 = new System.Data.SqlClient.SqlCommand())
                    {
                        command1.CommandType = System.Data.CommandType.Text;
                        command1.Connection = sc1;
                        // DIRECTION :: Input
                        command1.CommandText = "SET @CountRows = (SELECT Count(*) as COUNTR FROM [Purchasing].[ShipMethod]);" +
                            "SELECT Name FROM [Purchasing].[ShipMethod];";
                        System.Data.SqlClient.SqlParameter parameter1 =
                            command1.Parameters.Add("@CountRows", System.Data.SqlDbType.Int);
                        parameter1.Direction = System.Data.ParameterDirection.Output;
                        using (System.Data.SqlClient.SqlDataReader reader = command1.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                _shippingNames.Add(reader["Name"] as string);
                            }
                        }
                        RecordCount = (int)parameter1.Value;
                        //The following value is now 6, the number of records inside the table
                    }
                }
            }
        }
    }

    An important note to make here, is if you are using the ExecuteReader on a statement and pass in Output parameters, you must close the data reader before you can access these output parameter values.  In the above you will see that I encase the data reader in a using statement block.

    And finally to consume this example I use the following three lines:

                SimpleObjectOne newObject = SimpleObjectOne.GetSimpleObjectOne();
                int RecordCount = newObject.RecordCount;
                List<string> names = newObject.ShippingNames;
     

    I now have 6 as the record count and a list of shipping names.

    C# DateTime.MinValue is not the same as SqlDateTime.MinValue

    Working with non-nullable types in C# can be a bit of a pain. For instance when I have a date as a string and need to parse it into a DateTime what should the value be if the parse fails? I can’t use null because DateTime is not a nullable type.

    This is exactly the dilema I encountered today. No worries, I’ll use DateTime.MinValue that way it is constant and I don’t have to worry about being consistent if I had chosen an arbitrary value of my own.

    Well as it turns out I did have some worries. Sql Server 2000’s minimum DateTime value is not the same, in fact it is quite different. This kept causing errors.

    For your reference here are some values you should take note of.

    DateTime myDate = DateTime.MinValue; //=> 1/1/0001
    SqlDateTime mySqlDate = SqlDateTime.MinValue; //=> 1/1/1753
    //also note that SQL Server’s smalldatetime min value is 1/1/1900

    If you need to use the smalldatetime you will need to create your own property to do this

    So my problem was easily averted, after a quick Google search. I just had to use SqlDateTime.MinValue instead of DateTime.MinValue.

    How to debug stored procedures in Visual Studio .NET

    SUMMARY

    This step-by-step article explains two ways that you can debug SQL Server stored procedures and the necessary configuration settings and steps for each approach.

    A Visual Studio .NET developer can use the Server Explorer to debug SQL Server stored procedures independently of any Visual Studio project, or the developer can step into the code of the stored procedure directly from managed code in a Visual Basic, Visual C#, or Visual J# project.

    Debug a stored procedure in standalone mode

    1. Open Server Explorer.

    NOTE: It is not necessary to add a Data Connection to work with a SQL Server server because SQL Server servers are listed under the Servers node also. You will use the Servers node in the steps that follow; however, you can use a Data Connection to you SQL Server server in the same way.

    2. Under the Servers node in Server Explorer, expand the SQL Server machine name, expand the SQL Servers node, expand the SQL Server instance, expand the Northwind database node, and then expand the stored procedures node.

    3. Right-click the CustOrderHist stored procedure and then click Step Into Stored Procedure.

    4. The Run stored procedure dialog box opens, which lists the parameters of the stored procedure. Type ALFKI as the value for the @CustomerID input parameter and then click OK.

    5. In the Visual Studio design environment, a window opens that displays the text of the stored procedure. The first executable line of the stored procedure is highlighted. Press F11 to step through the stored procedure to completion.

    6. In the Output window, the following message is displayed, which indicates successful execution:
    The program 'SQL Debugger: T-SQL' has exited with code 0 (0x0). 

    Best Windows Backup Tool

    Carbonite

    Well I've been using Carbonite for over 2 years now and with almost 100Gbs backed up online it can't be bad.  Carbonite runs in the background all the time, so it is always backing up your data files.  It's a don't worry type of backup, just install it and leave it.

    If I find I need more processing speed or I here the hard drive working hard, then I can pause Carbonite for 24 hours, and it stops it's searching for changed files.

    It's so simple and restoring files are as easy as coping your files from one drive to another, as Carbonite creates virtual drive of the backed up files.

    Carbonite