Uros Calakovic
Чтобы ответить на этот вопрос, Деннис Валлентин предоставил код VBA для создания базы данных Sql Server CE здесь[^]. Копия кодекса для дальнейшего использования:
Option Explicit
'Reference to Microsoft ActiveX Data Objects x.x Library.
'Reference to Microsoft ADO Ext.x.x for DDL and Security
Sub Create_SSCE_Database()
'Name of the SSCE database.
Const C_stDBName = "XLDennis.sdf"
'Path to the SSCE database.
Const C_stPath = "C:\Users\Dennis Wallentin\Documents\SSCE\"
'Objects to create database, table and fields.
Dim xCat As ADOX.Catalog
Dim xTable As ADOX.Table
Dim xCol As ADOX.Column
Dim stConnection As String
'Connection string.
stConnection = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;" & _
"Data Source=" & C_stPath & C_stDBName & ";" & _
"Persist Security Info=False;"
Set xCat = New ADOX.Catalog
Set xTable = New ADOX.Table
'In case we have an already created database.
On Error Resume Next
Kill C_stPath & C_stDBName
On Error GoTo 0
'Create the empty database.
xCat.Create stConnection
'All the properties of the connection string is printed to
'the Immediate Window.
Debug.Print xCat.ActiveConnection
'Create a table with some fields.
With xTable
.Name = "ReportedData"
.Columns.Append "Department", adVarWChar, 10
.Columns.Append "Quater", adVarWChar, 6
.Columns.Append "Budget", adSmallInt, 4
.Columns.Append "Result", adSmallInt, 4
End With
'Add the created table to the database.
xCat.Tables.Append xTable
'Cleaning up.
Set xCol = Nothing: Set xTable = Nothing: Set xCat = Nothing
End Sub