sql-server-ce

Convert SQLCEResultSet resultview to datatable

混江龙づ霸主 提交于 2019-12-12 13:57:52
问题 Is it possible to convert a sqlceresultset.resultview to datatable? 回答1: Not tested, but this should do what you need: public DataTable ResultSetToDataTable(SqlCeResultSet set) { DataTable dt = new DataTable(); // copy columns for (int col = 0; col < set.FieldCount; col++) { dt.Columns.Add(set.GetName(col), set.GetFieldType(col)); } // copy data while (set.Read()) { DataRow row = dt.NewRow(); for (int col = 0; col < set.FieldCount; col++) { int ordinal = set.GetOrdinal(GetName(col)); row[col]

ObjectContext.SaveChanges() fails with SQL CE

 ̄綄美尐妖づ 提交于 2019-12-12 12:16:01
问题 I am creating a model-first Entity Framework 4 app that uses SQL CE as its data store. All is well until I call ObjectContext.SaveChanges() to save changes to the entities in the model. At that point, SaveChanges() throws a System.Data.UpdateException, with an inner exception message that reads as follows: Server-generated keys and server-generated values are not supported by SQL Server Compact. I am completely puzzled by this message. Any idea what is going on and how to fix it? Thanks. Here

Can't open .sdf file in VS 2012: Unspecified error

会有一股神秘感。 提交于 2019-12-12 12:09:48
问题 I am trying to open an .sdf file in Visual Studio Web Express 2012 . It's my local Orchard environment, but I suppose that doesn't matter much, as I have found this error all over the place when Googling. However I only found solutions for Visual Studio 2010 and lower, so they don't seem to apply to me, since they usually include installing Visual Studio 2010 Tools for SQL Server Compact. Which doesn't work with 2012 obviously. Here is the error when I try to open the file directly from VS

Can I have 2 different EntityFramework contexts share a single SqlServer Compact database?

梦想的初衷 提交于 2019-12-12 10:57:52
问题 I have a SqlServer Compact Edition database that contains 2 tables. For each of these tables, I have a context class derived from DbContext which is used by the application to access the table. In order to keep the different components of the application decoupled, I can't have one context class that would have DbSet properties for both of the tables. Rather, I need to have 2 different context class, each of them has to be completely unaware of the other and its data. I'm using the code-first

Access Violation Exception in SqlCeConnection dispose

為{幸葍}努か 提交于 2019-12-12 10:45:07
问题 Application/Code description: My application is based on c# and uses SQL Server CE and iv'e got this exception only twice at the same code location. the crash with this exception was not introduced till this version. the only change in this version was changing the .net framework to 4.5.2. I'm getting access violation exception on the dispose of an SqlCeConnection with the following error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

How can I add a column to an existing table?

穿精又带淫゛_ 提交于 2019-12-12 10:29:31
问题 How can I alter a table in SQL Server Compact Edition (SQL CE)? I have an existing table, and I need to add an IDENTITY column. 回答1: You add a column in the same way you would add it in other versions of SQL Server: This adds a primary key identity column called IdColumnName to the table tableName : ALTER TABLE tableName ADD COLUMN IdColumnName INTEGER IDENTITY (1,1) PRIMARY KEY See the ALTER TABLE syntax for SQL Server compact edition. 回答2: Hope these examples help some one ALTER TABLE

Connecting to SQL CE db using SQLConnection

a 夏天 提交于 2019-12-12 08:36:36
问题 Pretty straightforward question. I'm building an app which reads data from a SQL Server 2005 instance. I wanted to run some tests on my laptop (which does not have SQL 2005) so I was looking at swapping in a local database for the purpose of the tests. I'm using VS2008 so the Compact Edition DB seemed a natural choice. I had hoped to just swap out my connection string, but it seems It will only let me connect to the CE database using the SqlCeConnection and not SqlConnection. Any way around

Best way to export SQL Server database to sqlite (or SQL Server Compact)

非 Y 不嫁゛ 提交于 2019-12-12 07:51:48
问题 Do someone know what would be the best way to transform a big SQL Server database to sqlite or SQL Server compact ? SQL Server database should be around 50-70Gb. There are some examples on internet (script schema) but I didn't find anything concluding about data. 回答1: You can use my Exportsqlce tool to create .sql files in sqlite format from a SQL Server database. Then run them using sqlite3.exe Download command line tools from https://github.com/ErikEJ/SqlCeToolbox/releases/tag/3.5.2

c# DateTime Misunderstanding [closed]

浪子不回头ぞ 提交于 2019-12-12 06:38:41
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . No longer relevant: In one of the comments below the OP mentions a private object DateTime() { throw new NotImplementedException(); } slipping in. It

SQL Ce 4 - How can I run DBCC CHECKIDENT

南笙酒味 提交于 2019-12-12 06:03:52
问题 I want to run DBCC CHECKIDENT on a SqlCe4 database but it wont let me. I need to reset the identity column as its messed up. I think because IDENTITY was turned off, an import of data was done and then IDENTITY turned on again so I guess its out of sync 回答1: There is no DBCC CHECKIDENT in SQL CE 4. You need to use ALTER TABLE. ALTER TABLE [MyTable] ALTER COLUMN [IdentityColumn] IDENTITY (999,1). 来源: https://stackoverflow.com/questions/6284485/sql-ce-4-how-can-i-run-dbcc-checkident