Microsoft KB Archive/304060

= PRB: SQL Server CE Replication Error Message: 28557 : &quot;The database is in an unusable state. &quot; =

Article ID: 304060

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft SQL Server 2000 Windows CE Edition

-



This article was previously published under Q304060



SYMPTOMS
When you try to synchronize a database, the following error message may occur with Microsoft SQL Server 2000 Windows CE Edition (SQL Server CE) Replication Synchronize:

Source: Microsoft SQL Server 2000 Windows CE Edition

Number: 80004005

NativeError: 28557

Description: Run

Error code 28557 means:

The database is in an unusable state. Delete it and recreate it.



CAUSE
The error message shown in the &quot;Symptoms&quot; section may occur if the application receives an error during the initial synchronization. When an error occurs during the initial synchronization process, the subscription is actually incomplete and does not contain all of the required metadata and system tables to successfully fix itself.



RESOLUTION
To resolve this problem, use these steps:
 * 1) Delete the locate database (.sdf file) on the device and then re-create the local database.
 * 2) Call the AddSubscription method.
 * 3) Perform the first synchronization and download the initial snapshot by calling the Initialize, Run and Terminate methods.



STATUS
This behavior is by design.



MORE INFORMATION
Multiple error messages may occur with SQL Server CE Replication Synchronize such as:

28557 The database is in an unusable state. Delete it and recreate it.

-or-

28560 OLE DB Execute Method failed; bad or invalid SQL statement.

-or-

25082 Unique indexes/constraints cannot be created over nullable columns.

-or-

25501 Error parsing query.

Error message 25501 may occur if the database has a primary key on a nchar column that is more than 255 characters. Due to the data type mapping, SQL Server CE must map nchar to ntext and you cannot have a primary key on a ntext data type.

Another issue is that you might exceed the Index limitation, which is only 32 for SQL Server CE. So, if an attempt is made to create a 33rd Index, the attempt fails on a CE device.

The Parameters collection in the Errors collection provides you with text that contains the cause of the failure.

You can enhance error checking for the application by including the following code: Sub ShowErrors(ErrColl As SSCEErrors)

'Initialize error variables to view error collection Dim ErrRec As Object 'SSCE.ErrorRecords Dim param As Object Dim strErr As String strErr = &quot;&quot;

For Each ErrRec In ErrColl strErr = strErr & &quot;Source: &quot; & ErrRec.Source & vbCrLf strErr = strErr & &quot;Number: &quot; & Hex(ErrRec.Number) & vbCrLf strErr = strErr & &quot;NativeError: &quot; & ErrRec.NativeError & vbCrLf strErr = strErr & &quot;Description: &quot; & ErrRec.Description & vbCrLf For Each param In ErrRec.Params strErr = strErr & &quot;Param&quot; & &quot; = &quot; & param.Param & vbCrLf Next param strErr = strErr & vbCrLf

Next ErrRec MsgBox strErr, vbOKOnly

End Sub

