sql-server-ce

Why are my LINQ INSERTS not persisting in SQL Server CE 3.5?

*爱你&永不变心* 提交于 2019-12-01 20:28:04
I am using LINQ to SQL with Sql Server Compact Edition 3.5 and VS2008. I have a very simple table (Tokens) with a uniqueidentifier primary key (TokenID) and two other nullable fields (UsedBy and UsedOn). I am trying to use LINQ to insert new rows into the table but for some reason they are not persisting. Here is my code: var connectionstring = "Data Source=|DataDirectory|\\MyData.sdf"; MyData db = new MyData(connectionstring) { Log = Console.Out }; Tokens token = new Tokens { TokenID = Guid.NewGuid() }; db.Tokens.InsertOnSubmit(token); //db.GetChangeSet(); db.SubmitChanges(); var tokens =

Update LinqtoSql database with new schema changes?

99封情书 提交于 2019-12-01 19:44:36
I have a Windows Phone 7 application that has been published to the marketplace. I'm using Sql CE with LinqToSql. When the app runs, it checks for the existence of a database from a connection string, and creates if it doesn't exist. using (CheckbookDataContext db = new CheckbookDataContext(DBConnectionString)) { if (!db.DatabaseExists()) { isNewLoad = true; db.CreateDatabase(); } } As I begin to plan new features, I foresee some changes to the database schema, whether it be adding a new column to an existing table, adding new tables, etc. How does one go about updating the already existing

Connecting C# to SQL Server Compact database

房东的猫 提交于 2019-12-01 19:25:59
Hi I'm trying to connect an SQL server compact database to my program and I want a button that deletes all entries from the database, when I Press said button the program throws an exception and gives the following error message "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)" Help Please? =] Sorry, Code

Why do I receive file share error if Sql Compact allows multiple connections?

房东的猫 提交于 2019-12-01 18:06:27
Here , it is said that Sql Server Compact allows up to 256 connections. But when I try to open 2 connections, I receive a file sharing error. How can I solve this? SqlCeConnection c1 = new SqlCeConnection("Data Source=testDB.sdf;Encrypt Database=True;Password=test;File Mode=shared read;Persist Security Info=False;"); SqlCeConnection c2 = new SqlCeConnection("Data Source=testDB.sdf;Encrypt Database=True;Password=test;File Mode=shared read;Persist Security Info=False;"); c1.Open(); c2.Open(); // throws SqlCeException c1.Close(); c2.Close(); There is a file sharing violation. A different process

SQL CE Max Length

[亡魂溺海] 提交于 2019-12-01 15:59:45
I need to store articles in an application for WP7. I just want to use a database so I can query by unread articles, etc, etc. I've run into one big problem with SQL CE in Mango-- there seems to be a limit of 4000 characters, and my article is 4200. And that isn't even the biggest one. How can I get around this limit, if at all? If not, will I have to use a different database or possibly just write stories to IsolatedStorage and manage the file references in the database? Matt Lacey The 4000 byte limit is imposed on varchar fields. If you want more then you'll need ot use ntext . See the list

To close or not to close connection in database

大憨熊 提交于 2019-12-01 15:58:14
I work with Windows-Mobile and Windows-CE using SqlCE and I dont know what better to do. To open connection when the program open, run any query's... update...delete database and close the connection after the program close? Or open connection run any query's..update...delete database and close the connection immediately? Nice. The answers are all over the place. Here's what I know from experience and interacting with the SQL Compact team: Closing the connection flushes the changes you've made, otherwise the engine waits for the flush period before doing it. It's a good idea to close the

SQL CE Max Length

徘徊边缘 提交于 2019-12-01 15:40:19
问题 I need to store articles in an application for WP7. I just want to use a database so I can query by unread articles, etc, etc. I've run into one big problem with SQL CE in Mango-- there seems to be a limit of 4000 characters, and my article is 4200. And that isn't even the biggest one. How can I get around this limit, if at all? If not, will I have to use a different database or possibly just write stories to IsolatedStorage and manage the file references in the database? 回答1: The 4000 byte

C# - ExecuteNonQuery() isn't working with SQL Server CE

房东的猫 提交于 2019-12-01 11:56:08
问题 I got some data inputed by the user that should be added to a Database File (.sdf). I've choose Sql Server CE because this application is quite small, and i didn't saw need to work with a service based database. Well any way. Here goes the code: public class SqlActions { string conStr = String.Format("Data Source = " + new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + "\\basedados.sdf"); public SqlCeConnection SQLCEConnect() { SqlCeConnection

Connecting to a SQL Compact file (.sdf) using an ADO connection in Delphi

孤人 提交于 2019-12-01 10:35:22
I'm attempting to use a local .sdf file as a means of temporary storage should the main database be unreachable. I have the .sdf file, but when I try to set it to the file it seems to not at all know if the .sdf exists. The current connection string I have currently is: Driver={SQL Native Client};Data Source=C::\users\username\desktop\file\MyData.sdf;Persist Security Info=False and for the Provider it generated for me: Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5 When I try to use the connection, I get a "Provider cannot be found. It may not be properly installed." The .sdf is most definitely in

Using SQl Server CE; Possible to Insert Only If Not Exists?

非 Y 不嫁゛ 提交于 2019-12-01 10:33:53
I'm trying to verify a simple 1 field table to determine if a record exists before inserting a duplicate. if not exists (select * from url where url = ...) insert into url... Can someone Help? Your code example will run in the full version of SQL, or you could rearrange to the following: insert into url select 'myvalue' where not exists (select * from url where url = 'myvalue') ChulioMartinez You might want to read this thread. performing-insert-or-update-upsert-on-sql-server-compact-edition In a nutshell a sqlce specific solution (using SqlCeResultSet) will provide the maximum performance.