sql-server-ce

Batch Select Sql in SQLite or SqlCE with C#

Is there anyway to batch two different select queries to either SQLite or SQLCE and get the two result sets back in C#? If not, is there an embedded database that handles this? ...

Date Insert in SQL CE with internationalization

Before changing the regional settings of my computer. i can save a data in my application using SQL CE. when i changed my regional settings, for internationalization purpose, i can't save anymore and no error thrown when inserting data through my application. One of the fields there is a DateTime. What might be the problem? ...

Windows Phone Series: Local SQL Server Mobile/Compact information

I know that this is jumping the gun slightly as it is early days but has anyone got any information on how we can build apps that take advantage of a basic local SQL database like you used(!) to in Windows CE/mobile 6.x? I can't find any info on the intertubes so maybe it hasn't been announced yet?? ...

SQL Compact Edition database corruption

Hi, Our product is using MS SQL Compact Edition on a Windows machine (laptop). It's basically a metadata index for files we have on the filesystem. Recently we have seen databases getting corrupted. This happens when the machine is very busy moving files around and has to do a tiny bit of database changes at the same time. I was som...

Reset AutoNumber(Identity Field) in DataBase

Hi All I Use a Sql Server Compact Edition DataBase File For Store the Data in My Windows Application Software.In this DataBase I have A Table With Identity Field.When I Insert A Record To the Table, identity Code increment Automatically.But When I Delete All Records From Table,And Insert Records Again,Identity Field don't Start From 1. ...

ObjectContext.SaveChanges() fails with SQL CE

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 serv...

Generating Entity Keys

I have run into my first dissapointment with Entity Framework 4. It turns out that SQL CE, when used with EF4, does not support autogenerated primary keys. I get a System.Data.UpdateException from OnjectContext.SaveChanges() with this message: Server-generated keys and server-generated values are not supported by SQL Server Compact. So...

How to find out whether SqlCe query Has rows?

Hi, In my simple db I use SqlCe and I cannot figure out how to correctly find out whether the query has rows or not. HasRows does not work. So far I have this: _DbCommand.CommandText="SELECT * FROM X" SqlCeDataReader reader=_DbCommand.ExecuteQuery(); if (reader.FieldCount!=0) //I thought it could work (O rows - 0 fields?), but its true...

GUID or int entity key with SQL Compact/EF4?

This is a follow-up to an earlier question I posted on EF4 entity keys with SQL Compact. SQL Compact doesn't allow server-generated identity keys, so I am left with creating my own keys as objects are added to the ObjectContext. My first choice would be an integer key, and the previous answer linked to a blog post that shows an extension...

How to connect to SQL Server from another computer?

Hi, I want to connect from home using SQL Server 2005 to another PC. I had a look on the msd...but before connecting it says I should connect to another computer using the computer management and it didn't work out....I can only connect to computers from my workgroup? Thanks, Luisa ...

Creating an SQL Compact file: Template or script?

I am writing an application that writes to SQL Compact files that have a specific schema, and I am now implementing the New File use case. The simplest approach seems to be to use a Template pattern: first, create a template file that lives in the application directory. Then, when the user selects New File, the template is copied to the ...

LEFT OUTER JOIN with a WHERE clause

I have two tables. indRailType contains a list of the names paired with an ID value that I use in other tables to indicate the rail type. WO_BreakerRail contains a date column and a rail code colume that corresponds to the same code in indRailType and some other data. There's a row in WO_BreakerRail for any activity on each rail type, fo...

Compact Framework : Read a SQL CE database on a PDA from a PC

Hello, I have tasked with upgrading a CF Framework 1.1 suite of apps. Currently, the PC starts a server [after confirming via RAPI that the device exists and is connected] and spawns a app on the PDA as the client. The client process on the PDA talks with the db on the PDA and returns records to the PC app [using SQL CE 2.0. OpenNETCF ...

SQL Profiler and Tuning Advisor for Reporting Services - what events should be selected?

I've used the SQL Profiler to generate a trace file, and tuning advisor to take that trace file and provide some recommendations on db updates. However, the SQL Profiler doesn't seem to track the queries when running against a Reporting Server, the profiler doesn't seem to be capturing any of the queries. I'm logging the defaults (SQL:...

SqlCeException: The column cannot be modified. [ Column name = id ]

I am simply trying to add a single row in the database but I keep getting an exception. I created a local database and added a single table: users. It consists of two columns: "id" and "name". I only made the id primary key (not auto-increment or anything else). When I run the following code: string execPath = Path.GetDirectoryName...

Connect to SQL Server Compact Edition in SSIS

Till now I've been exporting data INTO the SQL Server CE database, but now in SSIS I'm attempting to source data that was inserted in a previous step of the import. The SSIS fails during validation with the following error Error: Microsoft.SqlServer.Dts.Runtime.DtsCouldNotCreateManagedConnectionException: Could not create a managed con...

NHibernate + Sql Compact + IoC - Connection Managment

When working with NHibernate and Sql Compact in a Windows Form application I am wondering what is the best practice for managing connections. With SQL CE I have read that you should keep your connection open vs closing it as one would typically do with standard SQL. If that is the case and your using a IoC, would you make your repositori...

How to store data in a table locally and present it in C#

I want to setup a table that can: Save the data on the user's machine Reference & present the data in the GUI Capable of adding rows dynamically during runtime What's the best way to go about this? DataGridView or TableLayoutPanel or...? I'm having trouble with SQL server CE, as I was going to connect it with the DataGridView, but ...

Can I recover lost data from an .mdf or .ldf file?

I have my .mdf and .ldf database files for a database named dbtrial. I accidentally deleted the data in one table. Is there any way to recover the lost data? ...

Using Entity Framework with an SQL Compact Private Installation

I am using Entity Framework 4 in a desktop application with SQL Compact. I want to use a private installation of SQL Compact with my application, so that my installer can install SQL Compact without giving the user a second installation to do. It also avoids versioning hassles down the road. My development machine has SQL Compact 3.5 SP...