sql-server-ce

SQL: Return only first occurrence

半腔热情 提交于 2019-12-05 03:14:14
I seldomly use SQL and I cannot find anything similar in my archive so I'm asking this simple query question: I need a query which one returns personID and only the first seenTime Records: seenID | personID | seenTime 108 3 13:34 109 2 13:56 110 3 14:22 111 3 14:31 112 4 15:04 113 2 15:52 Wanted result: personID | seenTime 3 13:34 2 13:56 4 15:04 That's what I did & failed: SELECT t.attendanceID, t.seenPersonID, t.seenTime (SELECT ROW_NUMBER() OVER (PARTITION BY seenID ORDER BY seenID) AS RowNo, seenID, seenPersonID, seenTime FROM personAttendances) t WHERE t.RowNo=1 P.S: Notice SQL CE 4 If

What is the difference between Shrink and Compact in SQL Server CE?

不问归期 提交于 2019-12-05 02:28:22
I have a method that is run periodically to optimise my application's SQL Server Compact Edition (3.5) database. The existing code uses the Shrink() method: SqlCeEngine engine = new SqlCeEngine(dbConnectionString); engine.Shrink(); Today I noticed that there's also a Compact() method. Which is preferable for periodic maintenance? From the SQL Server Compact Team Blog : The difference between these two is much similar to Internal and External Memory Fragmentation. From SqlCeEngine.Shrink documentation, Reclaims wasted space in the database by moving empty and unallocated pages to the end of the

EF Code first cascade delete on foreign key one-to-many

不问归期 提交于 2019-12-05 02:11:16
We are working in Entity framework Code first We have a class video class Video{ List<ImageInfo> Images{ get; set; } } our image infoclass contains a path to the image and some other info class ImageInfo{ String path; ... } we would like to have EF remove the imageinfos when removing the video so we changed the modelbuilder like follows: modelBuilder .Entity<Video>() .HasMany(v => v.Images) .WithRequired() .WillCascadeOnDelete(true); we don't want to add a link back to video in our imageinfo class. is it possible to get cascade delete functionality without a 2 way foreign key? EDIT the video

SQL Server CE database size issue

偶尔善良 提交于 2019-12-05 02:03:02
I have an application from a company that went out of business. It appears to use the SQL Server CE database. I have searched the system and can't find any .sdf files. It appears that the database has grown too big. Any idea how I can find the DB and change the maximum size? ERROR message: Unable to log application start. - System.Data.EntityCommandExecutionException: An error occurred while reading from the store provider's data reader. See the inner exception for details. ---> System.Data.SqlServerCe.SqlCeException: The database file is larger than the configured maximum database size. This

DataAdapter.Fill too slow

拜拜、爱过 提交于 2019-12-05 01:49:59
问题 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

How to identify whether the table has identity column

大兔子大兔子 提交于 2019-12-04 23:43:52
I want to find out whether the table has an identity column or not. Table is unknown to me. I have not done the structure of the table. Using Query? I am using Sql Server Compact Edition. Pranay Rana This is the query which return identity column name; create procedure GetIdentity @tablename varchar(50) begin SELECT OBJECT_NAME(OBJECT_ID) AS TABLENAME, NAME AS COLUMNNAME, SEED_VALUE, INCREMENT_VALUE, LAST_VALUE, IS_NOT_FOR_REPLICATION FROM SYS.IDENTITY_COLUMNS WHERE OBJECT_NAME(OBJECT_ID) = @tablename end Then form the code side. Call this stored procedure using the datareader role, then check

How to convert row to columns?

半世苍凉 提交于 2019-12-04 22:29:19
I have the below table: PROCESS ID VOUCHER DATE CATEGORY_ID PROJECT AMOUNT ----------- ------------ ------------ ------- ------- 1001 12/03/13 Miscellaneous pnr 1000 1001 12/03/13 Miscellaneous pjk 2000 1002 20/07/13 Local Travel pnr 3000 1002 20/07/13 Local Travel npk 3400 1003 29/09/14 Miscellaneous jpg 1000 1004 23/10/13 Local Travel pnr 2000 1005 24/10/13 Miscellaneous pnr 1000 1005 24/10/13 Local Travel pnr 1000 In the interface I will give VOUCHER DATE as between some date e.g., 20/01/13 and 27/10/13 and I have to get the output as in the format below: CATEGORY_ID pnr npk jpg -----------

Select from other table if value exist

不打扰是莪最后的温柔 提交于 2019-12-04 19:48:30
I created a fiddle for this, at this link: http://www.sqlfiddle.com/#!2/7e007 I could'nt find SQL compact / CE so it's in MySQL. The tables looks like this Records Clients ID | NAME | AGE ID | NAME ------------------ ---------------- 1 | John | 20 1 | John 2 | Steven | 30 2 | Daniel 3 | Abraham | 30 3 | 4 | Donald | 25 5 | Lisa 6 | | 35 6 | Michael 7 | | 42 7 | I would like to select from both tables, and if the id is in both tables and both have names I would like the the name from "Clients" as the default. If the name in Records is blank, use the client name (if any) and if the Clients.Name

SQLServerCE DefaultConnectionFactory

余生颓废 提交于 2019-12-04 19:28:17
I am using Entity Framework 4.1 and try to connect to a new SQLServerCE 4.0 database inside an MVC Web application. I am using this code Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", "|DataDirectory|", "test.sdf"); And it raises this exception : Format of the initialization string does not conform to specification starting at index 86. What's wrong with this code? If I use Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0") It works and creates a database with a very long name matching my assembly name. A

MVC4 - Membership - SQL Server Compact 4.0 - Exception: Unable to find the requested .Net Framework Data Provider

岁酱吖の 提交于 2019-12-04 19:24:47
The InitializeDatabaseConnection Method documentation says we can use the MVC 4 "Internet" template's generated membership functionality with SQLCE (SQL Server Compact 4.0 Local Database). I've used this template many times before and have never had a problem when I didn't fiddle with anything and simply used the localDb (the default) that is generated by the Entity Framework the first time we register a user. My requirement is to get the membership tables that are by default generated into 2012 localDb database instead to generate into a SQLCE database. However, I'm getting the following: