sql-server-ce

SQL Compact select top 1

老子叫甜甜 提交于 2019-12-04 00:24:52
While porting an application from SQL 2005 to SQL Server Compact Edition, I found that I need to port this command: SELECT TOP 1 Id FROM tblJob WHERE Holder_Id IS NULL But SQL Server Compact Edition doesn't support the TOP keyword. How can I port this command? Robinb SELECT TOP(1) Id FROM tblJob WHERE Holder_Id IS NULL Need the brackets as far as I know. reference: http://technet.microsoft.com/en-us/library/bb686896.aspx addition: likewise, only for version 3.5 onwards This is slightly orthogonal to your question. SQL Server Compact Edition actually doesn't perform very well with SQL queries.

How to delete all data in a table in SQL CE?

天大地大妈咪最大 提交于 2019-12-04 00:10:03
SQL CE does not support TRUNCATE command. To clear a table I have to use DELETE. Is there a quicker/better way to clear the data then the following command? DELETE FROM FooTable WHERE id !='ABC' You don't have any better way to do that, DELETE is the SQL Command for SQL CE to DELETE ROWS, anyway TRUNCATE TABLE deletes every row in a table, so your DELETE query must be executed also at SQL Server if you want to DELETE all the rows with id different from 'ABC'. In the case you want to DELETE all the rows in SQL CE you must use DELETE FROM FooTable See you, I hope this post was useful to you. No,

How do I rename a table in SQL Server Compact Edition?

試著忘記壹切 提交于 2019-12-03 23:28:08
I've designed my SQL CE tables using the built-in designer in VS2008. I chose the wrong names for a couple. I am now completely stuck trying to find a way to rename them. I am refusing to believe that such a feature could have been "forgotten". How do I rename an existing table using the VS2008 designer, or a free stand-alone app? Not sure about doing it via VS2008, but you can use sp_rename : Changes the name of a user table in the current database. Currently, sp_rename support in SQL Server Compact 3.5 is limited to tables. sp_rename [ @objname = ] 'object_name', [ @newname = ] 'new_name' [

EF6/SQL Server Compact, code-based configuration

好久不见. 提交于 2019-12-03 22:50:08
问题 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

SQLServerCE Problem with parameterized queries from .NET

南笙酒味 提交于 2019-12-03 18:11:33
问题 I am pulling the hair out of my head trying to figure this one out. I can't make Parameterized queries to work in VB.Net, when I am using parameters. From what I have found, using a parameter in a function, from .NET raises an error (see sample code). However, running the not working query in the Query Window in Visual studio works properly. The error raised is: 25922 - The arguments for function are not valid. Info from: http://msdn.microsoft.com/en-us/library/aa256772%28SQL.80%29.aspx

Programmatically create a SQL Server CE table from DataTable

怎甘沉沦 提交于 2019-12-03 17:34:15
Does anyone know the best way to create a SQL Server CE (Compact 3.5) table based on the schema of a DataTable at runtime? I don’t want to have to formulate a CREATE TABLE statement based on all the different possible datatypes, etc. As a bonus – do you then know how to fill it directly from a datatable? I've used and updated the Code from Ben Breen: Changed GetSqlServerCETypeName to work with all types Added a function fow a whole Dataset And some minor tweaks GetSqlDBTypeFromType /// <summary> /// Gets the correct SqlDBType for a given .NET type. Useful for working with SQL CE. /// </summary

How do you minimize the performance hit when upgrading to EF 4.1 from LINQ to SQL?

随声附和 提交于 2019-12-03 17:15:54
I recently updated an app with LINQ to SQL and SQL Server CE 3.5 to Entity Framework 4.1 Code First and SQL Server CE 4.0, and it's now running noticeably slower. I did some before vs. after stopwatch testing, and most major operations of my app appear to be running about 40% slower on average. I'm using all default strategies and configurations for EF Code First except for disabling cascading deletes. When I originally posted this question, I was focused on one query that seemed to be taking particularly long, but I've since realized that it was only particularly slow on first run (see the

DataAdapter.Fill too slow

谁说胖子不能爱 提交于 2019-12-03 16:28:38
I know DataAdapters have performance issues, but are there any ways around it that might be faster? At the moment, the DataAdapter.Fill method is taking 5-6 seconds on 3000 records, which is too slow for my app. If I remove the Fill line and just execute the SQL (using SQLCE), it takes 20 milliseconds, so I'm guessing the query isn't the problem. I've tried adding BeginLoadData on the datatable, but it makes no difference to the performance. using (SqlCeConnection con = new SqlCeConnection(conString)) { con.Open(); using (SqlCeDataAdapter dAdapter= new SqlCeDataAdapter()) { using (SqlCeCommand

Determine if table exists in SQL Server CE?

安稳与你 提交于 2019-12-03 15:18:13
问题 I know this is similar to this question, but I'm using SQL Server CE 3.5 with a WinForms project in C#. How can I determine whether a table exists? I know the IF keyword is not supported, though EXISTS is. Does information_schema exist in CE where I can query against it? Thanks. 回答1: Yes, it does exist: SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TableName' 回答2: As an alternative you can Query the Table and catch the Exception thrown. If there is an Exception, the Table wasn't

How to check a SQL Server CE database for indexes?

為{幸葍}努か 提交于 2019-12-03 12:17:13
Is there a way to list all SQL Server CE database table indexes, or at least for individual tables? -- Retrieves information about the indexes contained in the database. SELECT * FROM INFORMATION_SCHEMA.INDEXES -- Retrieves all the Tables in the database including the System tables. SELECT * FROM INFORMATION_SCHEMA.TABLES Arjuna Chiththananda - Retrieving Schema Information of SQL CE Database user497858 Thank you Arjuna! you pointed me in the right direction..... The following works. SELECT 'Y' FROM INFORMATION_SCHEMA.INDEXES where table_name = 'PP_JOB_TICKET_LIVE' and index_name = 'PP_JOB