My blog has moved!!

Monday, March 03, 2008
Last week I slipped an update in to Mini SQL Query - version 0.9.37.
Just minor fixes, updates, a quick start help page and I added a "Templates" tool window plugin...

Monday, March 03, 2008 10:30:11 AM (GMT Standard Time, UTC+00:00) |  |  | #
Friday, February 01, 2008

Mini SQL Query is one of those tools that I have had in my self coded toolbox for a long time now. Last year I almost released it to the public but a few things happened and the release sadly didn't. My apologies to those that were waiting, I had plenty of emails in the months to follow asking where the editor was!

 

Well, I finally uploaded the beta - see http://www.pksoftware.net/MiniSqlQuery/

 

 

Mini SQL Query hitting an MSSQL database.

 

Make sure you register so that when fixes or major releases are made you know – there is also the Mini SQL Query product RSS feed). Keep in mind its in no way intended as a replacement for Microsoft's "SQL Server Management Studio". I use it for making quick queries or updates to my databases. I find it particularly good for managing a remotely hosted database. I don't use it for modeling databases etc but I do plan on making a bunch of plugins to help with quickly putting together a NetTiers focused database model.

Mini SQL Query hitting an MS Access database with a table window floating.

 

The application itself it an exercise in minimalist coding. I made use of open source libraries such as the ICSharpTextEditor giving lots of edit functionality with little effort. I used Weifen Luo’s docking library which has been great (I need to track down the correct links etc will post later). The design employs a service model with commands which keeps code nicely separated and easily extendable (see the API docs on making plugins if you have the geekish urge to!) The testing is done with a combination of stubs and mocks (I use Rhino Mocks, just love the style...)

 

The whole application was actually coded with Microsoft Visual C# Express Edition. I wanted to see what a hobby developer IDE could come up with.

 

Some notes...

 

Multiple Connection Types

One of the main features is the fact that you can connect to pretty much any database so long as you know the Provider type and connection string. I have only had MSSQL and Access databases to test against so far but I might try and ressurect my Oracle instance just to check out the schema details.

Probaby the main usability thing to keep in mind is that if you change the provider type and/or the connection string you should hit the 'Refresh Database Connection' button/menu item. The 'Database Inspector' gets reloaded at this point too. 

 

Database Inspector

The inspector window shows basic details that are taken from the DBConnection.GetSchema output. I have noticed that some of the types for the access databases are not actually defined and so come though as a number with a question mark (e.g. 130? with is actually a variable string) .

 

Settings Persistance

There is none! I have not worried about it to date but that will turn up in time.

 

 

Let me know what you think, PK  :-)

Friday, February 01, 2008 2:43:45 AM (GMT Standard Time, UTC+00:00) |  |  | #
Thursday, June 07, 2007

I have had some questions regarding the icons (or rather images) that I use in my applications (such as the 'pending' Mini SQL Query tool)...

They are by Mark James - he has a bunch of great free stuff available at:
http://famfamfam.com/ - more so the "Silk" set at http://famfamfam.com/lab/icons/silk/

The images are licensed under a Creative Commons Attribution 2.5 License.

Thursday, June 07, 2007 10:05:56 AM (GMT Standard Time, UTC+00:00) |  |  | #
Monday, May 14, 2007

NOTE - Mini SQL Query has been released now - see http://www.pksoftware.net/blog/2008/02/01/Beta+Release+Of+Mini+SQL+Query.aspx.

 

This is not a product release, but a notice of release (!) for my latest pet project, "Mini SQL Query".

What is Mini SQL Query?...

"Mini SQL Query from PK Software is a minimalist SQL query tool for multiple providers (MSSQL, Oracle, OLEDB, MS Access files etc). The goal of the Mini SQL Query tool is to allow a developer or trouble-shooter to quickly diagnose issues or make changes to a database using a tool with a small footprint, that is fast, expandable and easy to use."
Some Features:
  • Multiple database type connections (e.g. MSSQL, Oracle, Access etc)
  • Syntax Highlighting
  • Object Inspector (Browse the tables, columns etc for the connection)
  • Easy to utilize Plug-In system that has access to all the applications internals
Sample Screenshot - The Mini SQL Query tool in use against the Northwind Sample DB:



I call it "mini" because I wanted to keep it simple and fast. I uses a straight forward but powerful plugin architecture that makes adding menu or toolbar options as simple as adding a reference in a DLL project and implementing a few functions from the IPlugIn interface. I will be pushing out a few posts about the service and command style of coding soon due to its implicit focus on issues such as dependency injection (DIP) and (dare I say it) service-oriented architecture (and no I am not talking about web services!) These techniques in turn improve code quality, testing and in turn maintenance (and again in turn our sanity as programmers...)

I will publish a core product and then make other plugins available for download.

Plugin Example 1...

Here is a simple example - display connection...



Below is the example C# plugin code that displays the current connection string in the editor window.

namespace MiniSqlQuery.Plugin.Example
{
    /// <summary>
    /// This example command inserts the current connection string details into the editor text.
    /// </summary>
    public class DisplayConnectionCommand : CommandBase
    {
        public DisplayConnectionCommand(IServiceContainer services)
            : base(services, "Display Connection Example")
        {
        }
        public override void Execute()
        {
            IEditor editorService = this.ServiceManager.CurrentEditor;
            editorService.Query = string.Format(
                "-- Connection: {0}\r\n\r\n{1}",
                this.ServiceManager.DatabaseConfigurationManager.ConnectionString,
                editorService.Query);
        }
    }
}

Running the menu command:



Simple I know but I wanted to show the command execution approach using services.

Plugin Example 2...

OK - not that exciting! Here is another example where a business object is generated from the result set...

Public Class MakeBusinessObjectFromResultsCommand
    Inherits CommandBase

    Sub New(ByVal services As IServiceContainer)
        MyBase.New(services, "Make BO from Results")
    End Sub

    Public Overrides Sub Execute()
        Dim editor As IEditor = Me.ServiceManager.CurrentEditor

        If Not editor.Result Is Nothing AndAlso _
         editor.Result.Tables.Count > 0 Then
            ' create some simple code gen using the results
            editor.Messages = GenerateClass(editor.Result.Tables(0))
        Else
            editor.Messages = "No results to generate code from."
        End If

    End Sub

    ''' <summary>
    ''' Given a DataTable (<paramref name="dt"/>), a basic VB.NET class is generated.
    ''' </summary>
    ''' <param name="dt">A DataTabel to generate a class from.</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GenerateClass(ByVal dt As DataTable) As String
        Dim code As New Text.StringBuilder()
        Dim fieldName As String
        Dim typeName As String

        code.AppendFormat("Public Class {0}{1}", dt.TableName, vbCrLf)
        code.AppendLine()
        code.AppendFormat(" Public Sub New{0}", vbCrLf)
        code.AppendFormat(" End Sub{0}", vbCrLf)
        code.AppendLine()
        For Each column As DataColumn In dt.Columns
            fieldName = "_" + column.ColumnName
            typeName = column.DataType.FullName
            code.AppendFormat(" Private {0} As {1}{2}", fieldName, column.DataType.FullName, vbCrLf)
            code.AppendLine()
            code.AppendFormat(" Public Property {0}() As {1}{2}", column.ColumnName, typeName, vbCrLf)
            code.AppendFormat(" Get{0}", vbCrLf)
            code.AppendFormat(" Return {0}{1}", fieldName, vbCrLf)
            code.AppendFormat(" End Get{0}", vbCrLf)
            code.AppendFormat(" Set(ByVal value As {0}){1}", typeName, vbCrLf)
            code.AppendFormat(" {0} = value{1}", fieldName, vbCrLf)
            code.AppendFormat(" End Set{0}", vbCrLf)
            code.AppendFormat(" End Property{0}", vbCrLf)
            code.AppendLine()
        Next

        code.AppendFormat("End Class")

        Return code.ToString()
    End Function

End Class


Running this command against the "select * from customers" query produces the following:

Public Class Table

    Public Sub New()
    End Sub

    Private _CustomerID As System.String

    Public Property CustomerID() As System.String
        Get
            Return _CustomerID
        End Get
        Set(ByVal value As System.String)
            _CustomerID = value
        End Set
    End Property

    Private _CompanyName As System.String

    Public Property CompanyName() As System.String
        Get
            Return _CompanyName
        End Get
        Set(ByVal value As System.String)
            _CompanyName = value
        End Set
    End Property

    Private _ContactName As System.String

    Public Property ContactName() As System.String
        Get
            Return _ContactName
        End Get
        Set(ByVal value As System.String)
            _ContactName = value
        End Set
    End Property

    Private _ContactTitle As System.String

    Public Property ContactTitle() As System.String
        Get
            Return _ContactTitle
        End Get
        Set(ByVal value As System.String)
            _ContactTitle = value
        End Set
    End Property

    Private _Address As System.String

    Public Property Address() As System.String
        Get
            Return _Address
        End Get
        Set(ByVal value As System.String)
            _Address = value
        End Set
    End Property

    Private _City As System.String

    Public Property City() As System.String
        Get
            Return _City
        End Get
        Set(ByVal value As System.String)
            _City = value
        End Set
    End Property

    Private _Region As System.String

    Public Property Region() As System.String
        Get
            Return _Region
        End Get
        Set(ByVal value As System.String)
            _Region = value
        End Set
    End Property

    Private _PostalCode As System.String

    Public Property PostalCode() As System.String
        Get
            Return _PostalCode
        End Get
        Set(ByVal value As System.String)
            _PostalCode = value
        End Set
    End Property

    Private _Country As System.String

    Public Property Country() As System.String
        Get
            Return _Country
        End Get
        Set(ByVal value As System.String)
            _Country = value
        End Set
    End Property

    Private _Phone As System.String

    Public Property Phone() As System.String
        Get
            Return _Phone
        End Get
        Set(ByVal value As System.String)
            _Phone = value
        End Set
    End Property

    Private _Fax As System.String

    Public Property Fax() As System.String
        Get
            Return _Fax
        End Get
        Set(ByVal value As System.String)
            _Fax = value
        End Set
    End Property

End Class


Motivation

My main motivation was the lack of speed I experience (no matter how fast my dev box) in using the "default" tools for SQL development. No way of customizing things easily further frustrated me. With a tool such as Mini SQL Query I can quickly add extras as I need them. For example, one plugin I plan of adding is focused on Access databases, I want to be able to write a query in an editor and push the .Net code to execute that query straight into my development project.

I will but publishing a first cut within the next couple of weeks and from there get some feedback etc.

Monday, May 14, 2007 2:38:15 AM (GMT Standard Time, UTC+00:00) |  |  | #
Search
Links
Products
Mini SQL Query
Mini SQL Query is a minimalist SQL query tool for multiple providers (MSSQL, Oracle, OLEDB, MS Access files etc.)

Verse Popper
The "Verse Popper" displays bible verses periodically in the lower right hand corner of your screen.

Categories
Blogroll
 PK Software DevBlog
My new blog!