sql-server-ce

Insert, Update, Delete are not applied on SQL Server CE database file for Windows Mobile

独自空忆成欢 提交于 2019-12-11 22:57:28
问题 I am developing a Windows Mobile 6.5 application with C# using Visual Studio 2008, it's connected to a SQL Server CE database. I used this code to insert rows, the value of each column is related to a textBox string : namespace GesTPL { public partial class Form4 : Form { public Form4() { InitializeComponent(); } public Form RefToForm1 { get; set; } static String pathDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); static String

Invalid option specified in CREATE INDEX statement

♀尐吖头ヾ 提交于 2019-12-11 22:48:32
问题 I'm trying to create a table which should ignore any duplicate value, using SQLCE. To do this, I figured I would select a column to be the index and use the IGNORE_DUP_KEY option. When I run the code below: CREATE NONCLUSTERED INDEX url_index ON Person (url ASC) WITH (IGNORE_DUP_KEY=ON) I get an error message saying "Invalid option specified in CREATE INDEX statement. [option name = IGNORE_DUP_KEY]." Is this because I'm using SQLCE? If so, how can I ignore duplicates in SQLCE? 回答1: The only

DllGetClassObject return “No such interface supported” while CoCreateInstance can find it successful

别等时光非礼了梦想. 提交于 2019-12-11 20:07:11
问题 I want to use the library "sqlceoledb35.dll" to process .sdf db file without register. I know this dll is a COM dll and used in ADO. But I can't get the target interface, it returns error "No such interface supported". Here is the code: CoInitialize(nullptr); HMODULE hmod = CoLoadLibrary((L"sqlceoledb35.dll"), true); DllGetClassObject_t pDllGetClassObject =(DllGetClassObject_t)GetProcAddress(hmod, "DllGetClassObject"); HRESULT hr=NOERROR; IDBInitialize *pIDBInitialize1=NULL; IDBInitialize

Linq-to-SQL database file empty

女生的网名这么多〃 提交于 2019-12-11 19:29:58
问题 I'm new to stackoverflow an I've searched the whole site and the msdn and found nothing. I hope you can help me! I want to have a Linq-to-SQL database in an .sdf file. So I designed the database sheme in the ORM designer for Linq-to-SQL and wrote the following code: DataShemeDataContext context = new DataShemeDataContext("Data Source=database.sdf"); if (!context.DatabaseExists()) context.CreateDatabase(); Console.ReadLine(); My problem is the following: when I run the program and exit it by

can anyone think of why using this particular class in a design time data source will break all design time bindings?

微笑、不失礼 提交于 2019-12-11 19:23:23
问题 I generated this class using SQLMetal.exe. It is very bindable at runtime, but if I use this class at design time, all of my design time blend bindings are busted. I am using the MVVM-Light framework and I am building an app for WP7. If I extract an interface for this class, and create a simple POCO that implements this interface and I use my simple poco in my design time data source, all of the bindings come alive. Here is the class that was generated by SQLMetal.exe. [Table(Name=

SQL Server CE's DDL parser is very picky but secretive about what it is finding fault with

谁都会走 提交于 2019-12-11 18:54:52
问题 I keep getting "there was an error parsing the query" no matter what I try with my DDL. So I need an expert in the SQL-Server-CE flavor of SQL to tell me which of the following is the preferred method (or something else, quite likely). Note that I'm not worried about "SQL injection" with these string format elements: 1) string ddl = string.Format("ALTER TABLE {0} ADD salvationID nvarchar(19)", tablename); ddl = string.Format("UPDATE {0} SET redemptionID = ''", tablename); 2) string ddl =

How to add record to SQL Server Compact

非 Y 不嫁゛ 提交于 2019-12-11 17:52:41
问题 I have looked at many videos and answers, on the web I now have a working example. I wish to drag and drop files onto a panel and have the name I provide plus a path to the file recorded into the database. Some examples show three lines for the SQL part I have one. SqlCeCommand cmd = new SqlCeCommand("INSERT INTO NStacks(NStacksName, NStacksItem)VALUES((textBox1.Text) + (File))", con); Others have different lines. When the program is executed normally without the SQL query then the line

C#: SqlCe Question, cannot update to database, but can read data

此生再无相见时 提交于 2019-12-11 17:17:11
问题 This code reads and updates the form fine when I run the program, but it does not update when I edit the values in the datagridview and click update. I am following a video tutorial series and this code does work in the video to update the table. Question: Why does it not update when I edit the values in the datagridview? using System.Data.SqlServerCe; namespace WindowsFormsApplication2 { public partial class Form1 : Form { private SqlCeConnection conn; // Our Connection private

SQL CE 3.5 - Writing to a database

旧城冷巷雨未停 提交于 2019-12-11 16:23:36
问题 I'm trying to write to a data base, I have been working of the following site. In particular the LoadARow function. I have been getting the runtime error "System.IndexOutOfRangeException: A SqlCeParameter with ParameterName 'Value' is not contained by this SqlCeParamaterCollection. The error references the line "command.Parameters["@Value"].Value = num;". The database I'm using has a Value column set as the key, and a text column. using (SqlCeConnection connect = new SqlCeConnection("Data

Comparing DateTime in Entity Framework with an Sql Server Compact database

风格不统一 提交于 2019-12-11 16:05:28
问题 Why this code throws a System.NotSupportedException telling that The specified method 'int? DateDiff(string, DateTime?, DateTime?)' on the type 'System.Data.Objects.SqlClient.SqlFunctions' cannot be translated into a LINQ to Entities store expression , though DateDiff has EdmFunction attribute? context.Users.Where(f => System.Data.Objects.SqlClient.SqlFunctions.DateDiff("second", f.LastLogOn, somedatetime) < 0) 回答1: Here is a complete enumeration of canonical Date and Time functions supported