Well, I just used the default code as proposed by the gettingstarted.pdf but changed it to vb
Sub SetConnection()
If (esConfigSettings.ConnectionInfo.Default <> "SiteSqlServer") Then
Dim ConnectionInfoSettings As esConfigSettings = esConfigSettings.ConnectionInfo
For Each connection As esConnectionElement In ConnectionInfoSettings.Connections
'if there is a SiteSqlServer in es connections set it default
If (connection.Name = "SiteSqlServer") Then
esConfigSettings.ConnectionInfo.Default = connection.Name
Return
End If
Next
'no SiteSqlServer found grab dnn cnn string and create
Dim dnnConnection As String = ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString
'Manually register a connection
Dim conn As esConnectionElement = New esConnectionElement()
conn.ConnectionString = dnnConnection
conn.Name = "SiteSqlServer"
conn.Provider = "EntitySpaces.SqlClientProvider"
conn.ProviderClass = "DataProvider"
conn.SqlAccessType = esSqlAccessType.DynamicSQL
conn.ProviderMetadataKey = "esDefault"
conn.DatabaseVersion = "2005"
' Assign the Default Connection
esConfigSettings.ConnectionInfo.Connections.Add(conn)
esConfigSettings.ConnectionInfo.Default = "SiteSqlServer"
'Register the Loader
esProviderFactory.Factory = New EntitySpaces.LoaderMT.esDataProviderFactory
End If
End Sub
I checked in debug mode and all seems to work well. This code is called and works fine.
But I think I know what is the problem. I'm trying to create a new record in a way that is not documented (and just isn't possible apparently ;) ) I tried to declare a new Employees() object and change the properties and then save.
I now trying it the documented way by creating an object through the collection. Probably that will work.