Microsoft KB Archive/271592

= INFO: Cannot Create a SQL Server CE Database on Connection.Execute =

Article ID: 271592

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft SQL Server 2000 Windows CE Edition

-



This article was previously published under Q271592



SUMMARY
If you create a SQL Server CE database by using the Microsoft ActiveX Data Objects (ADO) for Windows CE 3.1 (ADOCE) Connection.Execute method, you may receive the following error message when you try to open it:

An Error was encountered while running this program: Unspecified Error

You can use ADOXCE Catalog object to create a SQL Server CE database.



MORE INFORMATION
The following Visual Basic program demonstrates the problem and resolution:
 * 1) Create three command buttons and paste the sample code in a Visual Basic project.
 * 2) Add references to Microsoft CE SQL Server Control 1.0, Microsoft CE ADO Control 3.1, and Microsoft CE ADO Ext. 3.1 for DDL.

Sample Code
Option Explicit

Private Sub Command1_Click

' Incorrect Dim cn As ADOCE.Connection Set cn = CreateObject(&quot;ADOCE.Connection.3.1&quot;) cn.Open cn.Execute &quot;CREATE DATABASE &quot;&quot;\ssce.SDF&quot;&quot;&quot; cn.Close End Sub

Private Sub Command2_Click

' Open it; gives unspecified error after the above, works for the following. Dim cn As ADOCE.Connection Set cn = CreateObject(&quot;ADOCE.Connection.3.1&quot;) cn.ConnectionString = &quot;Provider=Microsoft.SQLSERVER.OLEDB.CE.1.0; data source=\ssce.SDF&quot; cn.Open cn.Close End Sub

Private Sub Command3_Click

' Correct Dim cat As ADOXCE.Catalog Set cat = CreateObject(&quot;adoxce.catalog.3.1&quot;) cat.Create &quot;Provider=Microsoft.SQLSERVER.OLEDB.CE.1.0;data source=\ssce.SDF&quot;

End Sub -

Keywords: kbinfo KB271592

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.