sql-server-ce

“Error parsing the query” while getting @@Identity from SQL Server CE

感情迁移 提交于 2019-12-02 19:20:18
问题 I'm writing a simple desktop application in which I'm using a local SQL database (SQL Server CE). Here is the problematic section: SqlCeConnection conn = new SqlCeConnection("Data Source=|DataDirectory|\\App_Data\\Rosters.sdf"); System.Data.SqlServerCe.SqlCeCommand cmd = new SqlCeCommand(); cmd.Connection = conn; cmd.CommandText = String.Format("Insert into Teams (LeagueID, TeamName, Color) values ({0},'{1}','{2}');SELECT @@IDENTITY;", leagueID, txtTeamName.Text.Replace("'", "''"), txtColor

How can I select what columns come in from a DataSet into a DataTable?

▼魔方 西西 提交于 2019-12-02 18:04:41
问题 Being new to working with Data, I hope I'm asking this properly. How can I select what columns come in from a DataSet into a DataTable? I know I can fill a DataTable by using... DataTable table = dataSet1.Tables[0]; but this brings in all the columns. How can I fill a DataTable with only certain columns? I'm using .NET 3.5, C#, and a SQL CE 3.5 single table database. Thanks. 回答1: // Assumes that connection is a valid SqlConnection object. string queryString = "SELECT CustomerID, CompanyName

Insert many rows to one table OR insert rows separately to many table?

孤者浪人 提交于 2019-12-02 17:51:48
问题 I have two DataBase Table (SQL CE). A Teacher table and a A Class table. The two tables have One-to-Many relationship where one teacher has many classes (i.e. Class has a foreign key teacher_id ). Number of teachers (rows) is inserted (or generated) through C# code in run time, so as classes Which of the following is faster in INSERT and SELECT? Each time a new teacher is INSERTed, a new Class Table is created (e.g. Class_teacher001) to store whichever classes the teacher has. In this case,

Does Sql Server CE supports MERGE statement

孤者浪人 提交于 2019-12-02 16:16:19
问题 I'm trying to run a MERGE query against a Sql Server CE database but it's throwing the error : There was an error parsing the query. ... while the same query is working fine in Sql Server . is merge statement not supported in Sql Server CE at all ? if so , is there any equivalent statement for CE ? MERGE [Books] as T USING(SELECT 1 S) as S ON T.Category ='Fiction' AND T.Lang='En' WHEN MATCHED THEN UPDATE SET Title=@Title WHEN NOT MATCHED THEN INSERT (Id , Title , Lang , Category) VALUES (@Id

How can a SQL Server CE database be simultaneously connectable and un-?

人盡茶涼 提交于 2019-12-02 16:09:34
问题 I have a SQL Server CE database in my Windows CE app. I can see it (HHS.sdf) in my project in Server Explorer: ...but the Columns folders for the tables won't expand; clicking them gives me: The path property for HHS.sdf reads: Data Source=Mobile Device\Program Files\hhs\HHS.sdf If the path is not valid, why is Server Explorer showing me the database at all? If I create a new connection in Server Explorer (by selecting "Add Connection..." from the Data Connections context menu), I can

How to decipher/interpret the contents of a file as shown in a Hex editor?

六眼飞鱼酱① 提交于 2019-12-02 13:02:23
In connection with this question , I downloaded a Hex Editor to see just what values my SDF file contained in a certain location, which is supposed to tell me what version of SQL Server CE the SDF file was created with. I got the following info: SQLCE Version 2.0: 0x73616261 3.0: 0x002dd714 3.5: 0x00357b9d 4.0: 0x003d0900 ...from this page . But I don't know what I'm looking at; I don't know if I'm looking in the wrong column or row, and I know that once I do know where I need to be looking, that data has to be converted to correspond with what is shown in the chart above. Can somebody tell me

Windows Phone 7 SQL Server CE rowversion

*爱你&永不变心* 提交于 2019-12-02 13:01:02
I had a problem when updating a table in SQL Server CE on Windows Phone 7. When I would call submit changes the app would close without any exceptions or errors. Visual Studio even remained running. Removing the rowversion column fixed the problem. I've looked around and not sure if I'm missing something but is there anything special one needs to do when using a rowversion column? Here are the attributes for the column. I created a simple table when trying to figure this out. It has 3 columns: Id (Guid) TestColumn (nvarchar100) MyRowVersion (rowversion) Code: [global::System.Data.Linq.Mapping

Model-First Entity Framework Max String Length of 4000

一笑奈何 提交于 2019-12-02 12:45:24
问题 For a project I have a SQL Server CE 3.5 database. It is accessed / created through entity framework with the model-first approach. Now I have some String typed columns in my EDMX, which have the max length specified. EDMX declaration <Property Name="Description" Type="nvarchar" Nullable="false" MaxLength="Max" /> The generated code ( *.sqlce file) shows that from the max-length string column in the model a nvarchar(4000) column is generated. .edmx.sqlce file (sql to create the database)

SQL Server Compact Edition 3.5 gives “Multiple-step operation generated errors” error for simple query

北战南征 提交于 2019-12-02 12:29:43
问题 I'm using a SQL Server CE database via Microsoft's OLEDB 3.5 SQL CE Driver. Here's my connection string: Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=C:\Users\me\Desktop\test1.sdf This query works fine: SELECT Thing FROM OtherThing WHERE name = 'TextThing' This query fails: SELECT Foo FROM Stuff And this is the error I get: Multiple-step operation generated errors. Check each status value. The only structural difference in the table themselves is that one has a text primary key and

In what format does SqlCeConnection expect its connection string arg?

百般思念 提交于 2019-12-02 11:56:42
问题 I have a call to SqlCeConnection.Open() that's failing. The exception message I'm getting is pretty generic: "System.Data.SqlserverCe.SqlCeException" (more generic than pretty) The pertinent code is: private DBConnection() { try { string conStr = "Data Source = " + filename; string cmpStr = conStr + ".tmp"; if (File.Exists(filename+".tmp")) File.Delete(filename+".tmp"); engine = new SqlCeEngine(conStr); if (File.Exists(filename)) { } else { engine.CreateDatabase(); } engine.Dispose(); objCon