sql-server-ce

Create SQLCE database programmatically [duplicate]

孤者浪人 提交于 2019-11-28 09:04:56
This question already has an answer here: Create SQL Server CE database file programmatically 2 answers [EDITED - with answer] Following is my code to create SQL CE database programmatically: /* get the Path */ var directoryName = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var fileName = System.IO.Path.Combine(directoryName, "Foo2Database.sdf"); /* check if exists */ if (File.Exists(fileName)) File.Delete(fileName); string connStr = @"Data Source = " + fileName; /* create Database */ SqlCeEngine engine = new SqlCeEngine(connStr); engine.CreateDatabase(); /* create

Exponentially deteriorating performance on inserts in SQL Server Compact 4.0 tables with an Identity column

限于喜欢 提交于 2019-11-28 08:17:20
问题 EDIT: the issue below has been fixed in the Entity Framework 6. Running the code below takes a disappointing 2 minutes and 10 seconds. Running it a second time takes 6.5 minutes. This question is related to this one Private Sub RunTest() Dim sw As New Stopwatch sw.Restart() Using db As New TestDB db.Configuration.AutoDetectChangesEnabled = False For n = 1 To 100 For m = 1 To 100 db.Tops.Add(New Top) Next Next db.SaveChanges() End Using MsgBox(sw.Elapsed.ToString) End Sub The Entity: Public

SQL Server Compact Edition ISNULL(sth, ' ') returns a boolean value?

守給你的承諾、 提交于 2019-11-28 08:07:37
问题 I have an Accounts table with columns name, password and email . They are all type nvarchar . I wrote a query like SELECT name, password, ISNULL(email, 'eeee') FROM Accounts WHERE name = '" + textBox1.Text + "' AND password ='" + textBox2.Text + "'" I read the email as reader.getString(2) since it is nvarchar . As I read from the internet, if email is NULL, then it should return eeee . But it says System.boolean can not be translated to System.String . How can I correct this? Why does it

Subquery in SQL Server Compact Edition

半世苍凉 提交于 2019-11-28 07:57:14
问题 I'm trying to do this in a SQL Server CE database, but the database engine keeps reporting errors. SELECT C.guid, C.name, C.updated, C.hddsize, C.hddavailable, C.hddfree, C.ramsize, C.profiles, C.cpu, (SELECT COUNT(D.id) AS numprogs FROM ComputerData AS D WHERE D.computer_id = C.id) AS numprograms FROM Computers AS C; I've been told SQL Server CE supports subqueries. Is there something I'm doing wrong? 回答1: My only experiences in queries are with MySQL, but hopefully it is similar enough.

Should I call “SqlCeEngine.Upgrade()” when both the SDF file and the device are seemingly the same version (2)?

天涯浪子 提交于 2019-11-28 06:49:37
问题 This is a followup to a question here ctacke said there regarding SQL Server CE-related "issues" I was/am having: " The problem, as indicated by the error text, is that the SDF file was created by a version of SQL Compact that doesn't match the version of SQL Compact that the application is referencing. I wouldn't focus on the reported version numbers, just the fact that it knows there's a mismatch. If you don't know the version of the SDF, you can always look it up by reading a few bytes

SQL LocalDB vs SQL Server CE

岁酱吖の 提交于 2019-11-28 06:49:30
I have a small project that will have 1 user on 1 computer. The database will be rather small (probably less than 1 mb of data). I plan to use WPF and Entity Framework for that project. I came up with 2 potential database solutions for my project : SQL Server CE and SQL Server Express LocalDB (with SQL Server 2012). I have never worked with any of those, I'm more used to work with the full SQL Server 2008 installation. I also want it to be easy to install on the client. Ideally I'd like to just throw a bunch of files on a folder (along with my .exe file). So anybody here could suggest me the

Raw C++ code to display the names of tables in an SQL compact server using OLE DB

蹲街弑〆低调 提交于 2019-11-28 06:23:05
问题 Does anyone have a sample code that given the database file displays the names of all the user tables there? I am not interested in a .NET code, just the C++. I am trying to grok OLE DB to do the task - rocket science seems child play in comparison. 回答1: I'm going to assume SQL Server CE 3.0/3.1 but, for your reference, here are provider strings I'm aware of: SQL Server CE 3.0 / 3.1 - Microsoft.SQLLITE.MOBILE.OLEDB.3.0 SQL Server CE 3.5 - Microsoft.SQLSERVER.CE.OLEDB.3.5 Also, I will be

How can I make this query in SQL Server Compact Edition?

你说的曾经没有我的故事 提交于 2019-11-28 06:11:02
问题 this subquery works in SQL Server: select systemUsers.name, (select count(id) from userIncidences where idUser = systemUsers.id ) from systemUsers How can It be made in SQL Compact? Thanks! 回答1: Try this: SELECT su.Name, COUNT(ui.ID) FROM systemUsers su LEFT JOIN userIncidences ui ON ui.idUser = su.ID GROUP BY su.Name [Edit:] I originally had an INNER JOIN just like Tomalak, but I realized that this would exclude users with no incidents, rather than show them with a 0 count. That might even

Is Microsoft dropping support for SDF database files in Visual Studio?

不羁岁月 提交于 2019-11-28 06:09:21
In Visual Studio 2013 there is no longer an option to create .sdf SQL Server Compact databases in WebPages (WebMatrix) websites. I am no longer able to view .sdf database files in Visual Studio either. I downloaded the latest version of WebMatrix to open my .sdf database but WebMatrix crashes when I open my website. When I create a new empty site and add existing files, it crashes. I searched for days for a way to view and edit my .sdf database and nothing is working. I can no longer get Navicat SQL Server app to open a database. I cannot get LinqPad to open an .sdf database file, I cannot get

Ado connection to SQL Server Compact Edition 4.0

血红的双手。 提交于 2019-11-28 05:30:22
问题 I want to connect to SQL Server Compact Edition 4.0 from an old asp-classic site but i always get the error: "Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified. " I tried sCon = "Data Source=c:\temp\sqlcompact.sdf;Encrypt Database=True;Password=testtest;Persist Security Info=False;" and Update: Error: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if