Monday, July 3, 2017

Zumero and self-referencing SQL table

We've been using Zumero to synchronise between an on-premise database and devices which contain our UWP application.

Zumero works pretty well, but one issue I found was using integer identity primary keys in a foreign key relationship for columns in the same table.

i.e. Table.ColumnX references Table.PrimaryKeyColumn where the PrimaryKey column is an identity seeded integer.

Zumero is not able to support this relationship since at sync time, it doesn't retain referential integrity.
You're better off using a uniqueidentity (GUID) as the primary key in this case.

Thursday, March 13, 2014

SSRS and Numeric Superscripts

They said it couldn't be done. Well I did it.
The below code can be embedded in a SSRS report as custom code. It takes any number and returns the superscript value.

    Function Superscriptify(ByVal number As Integer)
        Dim superscripts As New System.Collections.Generic.Dictionary(Of Integer, Integer)
        superscripts.Add(0, 8304)
        superscripts.Add(1, 185)
        superscripts.Add(2, 178)
        superscripts.Add(3, 179)
        superscripts.Add(4, 8308)
        superscripts.Add(5, 8309)
        superscripts.Add(6, 8310)
        superscripts.Add(7, 8311)
        superscripts.Add(8, 8312)
        superscripts.Add(9, 8313)
        Dim returnString As String = ""
        Do While ((number Mod 10 <> 0) Or (number / 10 > 0))
            Dim remainder As Integer = number Mod 10
            returnString = ChrW(superscripts.Item(remainder)) & returnString
            number = Math.Floor(number / 10)
        Loop
        Return returnString
    End Function


Use as follows (set the expression of a textbox): =Code.Superscriptify(723)
This should result in: 723 

Friday, April 12, 2013

Visual Studio SQL Compare - Cannot Update or Generate Script

Using SQL Compare in Visual Studio is kinda great.

However if you find you cannot generate the change script, or update the database directly after comparing because the Update and Generate Script buttons are greyed-out / disabled (see below), this may be the reason: the version of the .NET framework.



Right-click on the database project, select Properties and go to the SQLCLR tab and change the Target Framework version. 


Wednesday, January 16, 2013

App.Config transforms for non-Web projects

So I was doing a simple winform app for a client today and added an app.config to store the connection strings.
"Hmmm, lemme use this *new* (for me at least) config transform magic", I thought to myself.

Sadly, it only supports web projects (web.config). D'oh!
But no fear, someone out there has bumped up against the same issue. Thanks :)


Thursday, April 5, 2012

Levels of abstraction

I can't honestly say i understood it all, but i liked this:
"To design quickly and confidently, we need to be able to try out ideas and verify hypotheses as fast as we think of them"

That makes sense to me.

Tuesday, June 28, 2011

Page_ClientValidate blocking Submit to server

So I was wanting to do some client-side validation and then call back to the server should the page suddenly have become in/valid, I called Page_ClientValidate from javascript.

This returns a boolean value. It also as a side-affect of setting the Page_BlockSubmit to false should the page is invalid.

Which in turn blocks anything from submitting back to the server.

So to get around this, just set Page_BlockSubmit to false and submitting back to the server works as expected.

Thanks to the forum link!

Friday, November 5, 2010

Goddamn Object not set to an instance...

"Object reference not set to an instance of an object."

I love non-descriptive error messages.
Perhaps a mention of which object is returning the error would be great. It certainly would help.

k'thnx bye