When I was writing my blogpost yesterday about Gallus I started by using SQL server compact edition. Because it is easy to use and more or less compatible with sql server.

And I found out that for my case sql server compact edition was less compatible. SQL server compact edition does not support multiple statements in one command. Which is what we do when we use QueryMultiple in dapper.

And you will happy to know that the person who wrote the errormessage doesn’t really care about you as the user.

Exception thrown by QueryMultiple

Exception thrown by QueryMultiple

There was an error parsing the query. [ Token line number = 2,Token line offset = 1,Token in error = select ]

Took me a few minutes to figure out what he really meant.

The Gallus code you will be glad to know worked just fine since it uses only one sql statement.

If you want to try this just nuget sql server compact edition into your project and change these methods in your Setupdatabase module.

Function Setup(withTestData As Boolean) As IDbConnection
        CreateDatabase()
        Dim db = New SqlCeConnection("DataSource=""test.sdf""; Password=""mypassword""")
        db.Open()
        CreateTables(db)
        If withTestData Then InsertTestData(db)
        Return db
    End Function

And

Private Function CreateDatabase() As SqlCeEngine
        If File.Exists("test.sdf") Then File.Delete("test.sdf")
        Dim en = New SqlCeEngine("DataSource=""test.sdf""; Password=""mypassword""")
        en.CreateDatabase()
        Return en
    End Function

I’m just leaving this here for my future self.