2014年7月13日 星期日

[RESOLVED] System.Data.SqlServerCe.SqlCeException


Hey I received the following error, and I think it is the limitation of SQL Server Compact 4.0, and it works on the normal SQL Server. 


Does anybody know what's going on?


DataAccess.Sql.SqlHelperException: [Sql=


                CREATE TABLE [com.avg.microsoft.hyperv-HyperV_HostNic]

                (

                    DeviceGuid      uniqueidentifier    NOT NULL,

                    OMRowVersion    timestamp           NOT NULL,

                    DateCreated     datetime            NOT NULL,

                    DateModified    datetime            NOT NULL,

                    SyncGuid        uniqueidentifier    NOT NULL CONSTRAINT [com.avg.microsoft.hyperv-HyperV_HostNic_SyncGuid_UC] UNIQUE,


                    CONSTRAINT [com.avg.microsoft.hyperv-HyperV_HostNic_PK] PRIMARY KEY CLUSTERED


                    (

                     [DeviceGuid]  ASC,

                        [SyncGuid]    ASC

                    )

                );

Sql]

[Arguments:


Arguments]

[INNER_EXCEPTION:

The constraint specified is not valid.

INNER_EXCEPTION]

 ---> System.Data.SqlServerCe.SqlCeException: The constraint specified is not valid.

   at System.Data.SqlServerCe.SqlCeCommand.CompileQueryPlan()

   at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)

   at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()

   at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteNonQuery(DbCommand command)

   at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DbCommand command)

   at LPI.DataAccess.Sql.SqlHelperGeneric.ExecuteNonQuery(String commandText, DbParameter[] parameterValues, Int32 timeoutInSeconds) in c:\Builds\106\Sources\Common\LPI.DataAccess.Sql\SqlHelperGeneric.cs:line 473

   at LPI.DataAccess.Sql.SqlHelperGeneric.ExecuteNonQuery(ParameterizedQuery qry, Int32 timeoutInSeconds) in c:\Builds\106\Sources\Common\LPI.DataAccess.Sql\SqlHelperGeneric.cs:line 496

   --- End of inner exception stack trace ---

   at LPI.DataAccess.Sql.SqlHelperGeneric.ExecuteNonQuery(ParameterizedQuery qry, Int32 timeoutInSeconds) in c:\Builds\106\Sources\Common\LPI.DataAccess.Sql\SqlHelperGeneric.cs:line 502

   at LPI.Sdk.Monitoring.OM.Data.DataAccess.SdkCustomSchemaProvider.CreateObjectTable(String schema, String table) in c:\Builds\106\Sources\OMSolution.root\OMSolution\LPI.Sdk.Monitoring.OM\Data\DataAccess\SdkCustomSchemaProvider.cs:line 116

   at LPI.Sdk.Common.DataAccess.CustomDataHelper.InstallUpdateCustomObjects(List`1 obj, String schemaName, ISdkCustomSchemaProvider schemaProvider, IManagedElementDataProvider metadataProvider) in c:\Builds\106\Sources\Common\LPI.Sdk.Common\DataAccess\CustomDataHelper.cs:line
73

   at LPI.PluginManagement.OM.PluginDeploymentManager.CustomDataCallback(Object args) in c:\Builds\106\Sources\OMSolution.root\OMSolution\LPI.PluginManagement.OM\PluginDeploymentManager.cs:line 201


Thanks,T



Have you tried using simpler table names and constraint names? Try diverging very simple without using periods or whatever. Maybe that makes a difference I don't really know. 



Removed


CONSTRAINT [com.avg.microsoft.hyperv-HyperV_HostNic_PK] PRIMARY KEY

(

[DeviceGuid] ASC,

[SyncGuid] ASC

)


and it works, but I want to keep these. Compactable version does not support the above??


T



Hi super123,


following lines are taken from MSDN forums,


"SQL Server Compact Edition does not support clustered indexes."


for details, please have a look at this link, thanks .


http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5003ac3e-f795-4da7-85b1-b2ed17806f6f/sql-compact-create-table-error-the-constraint-specified-is-not-valid


沒有留言:

張貼留言