Sunday, March 25, 2012

Connecting to SQL Mobile within VS-2005

I am getting an error when I run my project within VS2005. I am trying to connect to a SQL Mobile (sdf) file thru code using a connection string. As soon as run my project within the VS2005 environment, I get the following error when the code tries to connect:
"The file is not a valid database file. An internal error has occurred. [,,,Databasename,,]"
The source of the error is: Microsoft SQL Server 2000 Windows CE Edition
Native Error of: 25011
I am am deploying to POcket PC 2003 SE Emulator.
This code worked fine in VS2003 with SQLCE 2.0. But I have now updated the projects to VS2005 and recreated the database sdf file within the VS2005 environment.
Could someone please help me ASAP?
Thanks.

There is no database compatibility between SQL CE 2.0 and SQL Mobile. Database created through one cannot be opened by other. In you case, since you have upgraded the project and re-created the database, you have SQL Mobile database. But your application still has references to SQL CE 2.0 provider. So now your application is trying to open a SQL CE 3.0 Database using SQL CE 2.0 provider; that’s the reason why in your error string you can see

The source of the error is: Microsoft SQL Server 2000 Windows CE Edition
Native Error of: 25011

In you application you need to remove the reference from 2.0 provider and add reference to 3.0 provider.

Thanks

-Mani

No comments:

Post a Comment