sql-server-ce

How can I connect to a SDF database? No connection string I try seems to work

好久不见. 提交于 2019-11-29 10:22:57
I've tried literally 50+ different attempts at my connection string for my local database and nothing seems to work. I'm essentially just trying to open a connection the database file so I can dump in the data I've pulled out of my excel spreadsheet. I'm using Visual C# making an offline winform application. No matter what connection string I try in my app.config, it always fails when it tries to write "dReader" to the database. The error is usually this depending on what string I try: "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The

SQL CE 4.0 as a InstallShield Prerequisite

人走茶凉 提交于 2019-11-29 10:04:17
I'm making my own prq file to perform the SQL CE 4.0 installation with my WPF application installation. The installer keeps failing, and I'm not sure why. It looks like it attempts to run the CE exe, but then a Windows Installer help window comes up with all of these command line help options. I click OK, and then it says the installation of CE has failed. I don't how to determine what is going wrong. Here's my prq file contents: <?xml version="1.0" encoding="UTF-8"?> <SetupPrereq> <conditions> <condition Type="32" Comparison="2" Path="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server

Why doesn't SQL Server CE support varchar?

只谈情不闲聊 提交于 2019-11-29 09:14:24
I was creating a table in SQL Server CE and realized it doesn't support varchar. Looking this up, I found that "non-Unicode text columns (varchar, char, text) and smallmoney are not supported; although nvarchar, nchar, ntext, and money are supported" as stated at MSDN . Is this true? Why is this, exactly? It would seem that a compact database would support data types that take less bytes to store...I'm assuming it takes more space to save the Unicode characters. What is the reasoning behind this? It's probably because Windows CE is completely Unicode based and all of it's strings are stored

Create .mdf/.sdf database dynamically

烂漫一生 提交于 2019-11-29 08:00:03
问题 How can I with "code" create a new .mdf/.sdf database? I've tried this: http://support.microsoft.com/kb/307283 All it does is fail on the ConnectionString. Since I have no connection to a file that exists before I create it, how can I only connect to the SQL Express Server just to create a mdf/sdf database? I want to be able to just connect to the server and create the file, from there it probably will be easier to create the tables and such. Any suggestions? 回答1: public static void

Local DB throws Byte array truncation to a length of 8000 exception

江枫思渺然 提交于 2019-11-29 06:56:47
I'm trying to take a snapshot from a Map control as a WritableBitmap, convert it to a byte array and save it in the local DB. It works fine (I can convert the byte array back to the image) untill I submit the changes to the DB. At this point it throws an exception "Byte array truncation to a length of 8000". I didn't find any documentation about byte array limitation. Does anyone know how to increase the limit of 8000? My byte array is a member of my Model: private byte[] _locationImage; [Column] public byte[] LocationImage { get { return _locationImage; } set { if (_locationImage != value) {

Error storing Image in SQL CE 4.0 with ASP.NET MVC 3 and Entity Framework 4.1 Code First

安稳与你 提交于 2019-11-29 05:37:21
I'm trying to store/save an image in an SQL Compact Edition (CE) database. I declare the field in my Student model as: [Column(TypeName = "image")] public byte[] Photo { get; set; } The database is created with the image data type for the Photo column as can be seen here: The problem is: When I run the app and try to save a Student with a Photo of 3 MB (for example), I get an exception: validationError.ErrorMessage = "The field Photo must be a string or array type with a maximum length of '4000'." SQL Server CE supports these Data Types . In this comparison between SQL Express and SQL Compact

Performing Insert OR Update (upsert) on sql server compact edition

十年热恋 提交于 2019-11-29 05:17:18
I have c# project that is using sqlserver compact edition and entity framework for data access. I have the need to insert or update a large amount of rows, 5000+ or more to the db, so if the key exists update the record if not insert it. I can not find a way to do this with compact edition and EF with out horrible performance, ie taking 2 mins plus on a core i7 computer. I have tried searching for the record to see if it exists then inserting if not or update if it does, the search is the killer on that. I have tried compiling the search query and that only gave a small improvement. Another

Do Windows 8 Metro style application support SQL Server CE local database?

落爺英雄遲暮 提交于 2019-11-29 04:39:57
I have built a Windows Phone Application using SQL Server CE database. We need transplant this app to Windows 8 Metro Style. Do Windows 8 Metro-style applications support SQL Server CE local databases? As already answered by ErikEJ, there is no native support for a local SQL Server CE database, but maybe this third party component SQLite is usefull for you? Tim Heuer has wrote a blogpost about how to use SQLite in a metro style app: http://timheuer.com/blog/archive/2012/05/20/using-sqlite-in-metro-style-app.aspx In the blogpost there is also a video with the "How to" steps to use SQLite in

Connection string for using SQL Server Compact with Entity Framework?

泪湿孤枕 提交于 2019-11-29 04:02:05
I'm done trying to Google for this. I have installed SQL Server CE 4.0, and have EF 4.1, but I can't get a proper connection string. Nothing on connectionstrings.com applies to me. I just want to create a SqlCeEngine object, but no matter what I try I get some exception. Most recently it's been Unknown connection option in connection string with either "metadata", "app", "provider", or "provider connection string" after it. I know EF requires metadata in the connection string. And I can't imagine how anything could do without "provider connection string". So far I have this: <add name=

How do I select the first row per group in an SQL Query?

三世轮回 提交于 2019-11-29 03:18:47
问题 I've got this SQL query: SELECT Foo, Bar, SUM(Values) AS Sum FROM SomeTable GROUP BY Foo, Bar ORDER BY Foo DESC, Sum DESC This results in an output similar to this: 47 1 100 47 0 10 47 2 10 46 0 100 46 1 10 46 2 10 44 0 2 I'd like to have only the first row per Foo and ignore the rest. 47 1 100 46 0 100 44 0 2 How do I do that? 回答1: declare @sometable table ( foo int, bar int, value int ) insert into @sometable values (47, 1, 100) insert into @sometable values (47, 0, 10) insert into