I’m trying to access a Sql Server Compact Database.
It’s a clickonce application, so I’d like it if the database can be created when the application is installed.
I got it so that when the application is started the database is created by using SqlCeEngine, SqlCeConnection, etc.
However, querying and inserting this way is complicated, so I was hoping to get it working with ADODB.
Dim MyCn As New ADODB.Connection
MyCn.Provider = "Microsoft.SQLSERVER.CE.OLEDB.3.5"
MyCn.ConnectionString = My.Settings.LocalConnectionString
MyCn.Open()
Dim rSelect As New ADODB.Recordset
With rSelect
.Open("Select wID, DirPath, Children From Watches Where DirPath like '" & dialog.SelectedPath & "'", MyCn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly)
If .EOF Then
.AddNew()
.Fields!DirPath.Value = dialog.SelectedPath
.Fields!Children.Value = True
.Update()
End If
.Close()
End With
but I get an error:
In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.
Alternately, I wouldn’t mind learning how to use LINQ to SQL, as 3.5 supports it, but I haven’t found how to connect to a database that might not exist until the program starts for the first time, meaning I can’t use the database wizard.
Found some tutorials to use LINQ to SQL.
It’s not quite as easy to use as ADODB is with regular SQL Server, since you have to make classes for each table, but it’s not to bad.