sql-server-ce

How to convert DateTime of type DateTimeKind.Unspecified to DateTime.Kind.Utc in C# (.NET)

邮差的信 提交于 2019-12-01 02:07:28
I've inherited C# code that has an awful lot of DateTimes where the Kind property is DateTimeKind.Unspecified. These are fed into Datetime.ToUniversalTime() which gives back a UTC datetime (it adds 7 hours in my case). This is how ToUniversalTime() works; see MSDN. The problem is that these DateTimes are in fact already in UTC time. They are pulled out of a SQL Server Compact 4.0 database. They were stored there in UTC. My main question is: How do I modify the Kind property of a DateTime so that it's UTC and not Unspecified? I don't want to change the time or date. So for example, a date of

Using MS Sync Framework to synchronize two SQL CE Dbs

拥有回忆 提交于 2019-12-01 01:28:03
问题 I'm just working into the Microsoft Sync Framework. It looks quite easy to sync a local SQL CE 3.5 Database with a remote SQL Server 2008 using the SqlSyncAdapterBuilder and SqlServerChangeTracking. Unfortunately, syncing two SQL CE 3.5 Databases doesn't look that easy... The documentation is very sparse, and I don't realy know how to get started here. My concrete scenario looks like the following: I have one central SQL Server 2008. Multiple clients are connected to this server (some of them

EF6/SQL Server Compact, code-based configuration

无人久伴 提交于 2019-12-01 00:38:12
I'm trying to move my EF6 configuration from myexe.exe.config to code as a workaround for the empty DbProviderFactories node in machine.config -issue (described here: https://stackoverflow.com/a/24273922/600559 ). I don't want to change the machine.config file. I have read the Code-Based Configuration (EF6 onwards) . I have tried implementations like this: https://stackoverflow.com/a/23130602/600559 , however I cannot get it to work. Does anyone have a working EF6/SQL CE/code-based configuration solution? Here's my my changes (from a working .config solution to a code based solution): New

SQL Server CE - Internal error: Cannot open the shared memory region

微笑、不失礼 提交于 2019-11-30 21:34:02
I have a SQL Server CE database that works fine in dev, but when installed on the client has an issue. The SQL Server CE 3.5 dependencies are copied as part of the deployment. The target machine is a clean Windows 7 32-bit Ultimate image. The message for the exception in the event log is: Message: Internal error: Cannot open the shared memory region. Stack Trace: at System.Data.SqlServerCe.SqlCeConnection.ProcessResults(Int32 hr) at System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent) at System.Data.SqlServerCe.SqlCeConnection.Open() at System.Data.Linq.SqlClient.SqlConnectionManager

Store an image in a SQL Server CE database

☆樱花仙子☆ 提交于 2019-11-30 20:59:23
Does any one know of an example on how to store an image in a SQL Server CE database? What data type should the column be? (I am guessing binary.) I use Linq-To-Datasets. Is it possible using that to put the image into the database and pull it out again later? Thanks for any advice. Here is how I did it: MemoryStream stream = new MemoryStream(); myBitmapImage.Save(stream, ImageFormat.Png); myInsertLinqToDataSetRow.IMAGE_COLUMN = stream.ToArray(); To load it back out again I did this: MemoryStream stream = new MemoryStream(myLinqToDataSetRow.IMAGE_COLUMN); myBitmapImage.SignatureImage = new

Reverse boolean (bit) value in SQL CE select statement

故事扮演 提交于 2019-11-30 19:45:39
I am trying to write a query that gets table information from a SQL CE database, ready to be put in c#, later to be exported to XML. I need one of the columns to be named 'IDENT' with a boolean value (to represent whether or not it is the identity column, obviously). For this, I am checking if the AUTOINC_SEED column is null, as follows: select isnull(AUTOINC_SEED) as IDENT from information_schema.columns However, this returns TRUE for non-identity columns and FALSE for identity columns! Is there any way to reverse the boolean value inside the select statement? Edit: I'm aware I could do a

How to deploy SQL CE 4 CTP to shared hosting?

不羁的心 提交于 2019-11-30 19:35:39
How do I deploy SQL CE 4.0 with EF4 to a shared hosting provider for ASP.NET MVC 2.0? I've included System.Data.SqlServerCe.dll, and the amd64 + x86 directories in my bin folder, but keep getting a ".net provider not found". I realize it's currently in CTP, but this is just for testing purposes. My project + host is configured for .net 4.0 Loren Paulsen With Visual Studio 2010 there is now an easy way to deploy SQL CE 4 to a shared hosting environment through the use of "Deployable Dependencies". You do not need to manually copy dlls to your bin folder or modify your web.config. Both of these

A duplicate value cannot be inserted into a unique index [closed]

泪湿孤枕 提交于 2019-11-30 19:07:18
Self answering question for future reference: If you have a table where you deleted and re-added content, you can get this error while inserting new rows with an ID equal to existing IDs: Server Error in '/' Application. A duplicate value cannot be inserted into a unique index. [ Table name = Stories,Constraint name = PK__Stories__000000000000001C ] Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlServerCe

Convert .sdf database to .mdf database

左心房为你撑大大i 提交于 2019-11-30 18:51:55
问题 I have this SQL Server CE database (with more tables and data) which I would like to convert to SQL 2008 because I want use it in Server (application need to used by many). I am using SQL 2008 express and C#. Please suggest how I can do this. 回答1: Maybe a good idea is to try microsoft (free) tool, Sql Server Management Studio : http://www.microsoft.com/download/en/details.aspx?id=7593 回答2: Have you tried the Data Migration Wizard? Anyhow, you might find this interesting: http://exportsqlce

Opening an SQL CE file at runtime with Entity Framework 4

≡放荡痞女 提交于 2019-11-30 18:19:11
问题 I am getting started with Entity Framework 4, and I an creating a demo app as a learning exercise. The app is a simple documentation builder, and it uses a SQL CE store. Each documentation project has its own SQL CE data file, and the user opens one of these files to work on a project. The EDM is very simple. A documentation project is comprised of a list of subjects, each of which has a title, a description, and zero or more notes. So, my entities are Subject, which contains Title and Text