sql-server-ce

Select newly added Row - DataGridView and BindingSource

半城伤御伤魂 提交于 2019-11-28 04:47:34
问题 I'm adding a new Row to a BindingSource that is Bound to a DataGridView source.AddNew(); After this, use BindingSource to get the newly added row is return the next row in the DataGridView when its sorted. ROW "A" ROW "B" <- myBindingSource.AddNew(); ROW "C" myBindingSource.Current gives ROW "C". (it became the selected row in the DataGridView) I need this because I want to update just the newly added row DataRowView drv = (DataRowView)myBindingSource.Current; myTableAdapter.Update(drv.Row);

How can I determine whether a column exists in a SQL Server CE table with C#?

对着背影说爱祢 提交于 2019-11-28 04:39:32
问题 The legacy code does it this way: public bool isValidField(string tableName, string fieldName) { bool retVal; string tblQuery = string.Format("SELECT {0} FROM {1}", fieldName, tableName); checkConnection(); try { SqlCeCommand cmd = objCon.CreateCommand(); cmd.CommandText = tblQuery; object objvalid = cmd.ExecuteScalar(); retVal = (null != objvalid); } catch { retVal = false; } return retVal; } ...but I find it doesn't always work. After calling that method, and getting false , some code

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

时光毁灭记忆、已成空白 提交于 2019-11-28 03:40:30
问题 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

SQL CE 4.0 as a InstallShield Prerequisite

这一生的挚爱 提交于 2019-11-28 03:31:45
问题 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>

how to open *.sdf files?

半世苍凉 提交于 2019-11-28 03:08:24
I used to open sdf (sqlCE) files with visual-studio? or sql-server? I really don't remember. Now I can't open this sdf file. With what program do I need to open it? It's a SQL Compact database. You need to define what you mean by "Open". You can open it via code with the SqlCeConnection so you can write your own tool/app to access it. Visual Studio can also open the files directly if was created with the right version of SQL Compact. There are also some third-party tools for manipulating them. Chris Voon Try LINQPad , it works for SQL Server, MySQL, SQLite and also SDF (SQL CE 4.0). Best of

Running SQL Server CE 4 Queries with Visual Studio 2012 and SQL Server Management Studio 2012

霸气de小男生 提交于 2019-11-28 02:06:26
I have recently upgraded to Visual Studio 2012 and SQL Server Management Studio 2012, however I cannot seem to see how to execute SQL scripts (created by Entity framework) on a SQL Server CE 4.0 database. With VS2010 + SSMS 2008 the Transact-SQL editor would ask for a connection and you could browse to the object, however this option is not available in SSMS 2012. I have tried to execute the script via the Server Explorer -> New Query window, but I get parse errors. Any clues? Microsoft got rid of that for SSMS 2012, and suggested to use the integrated tools in WebMatrix instead (from memory,

C#/SQL - What's wrong with SqlDbType.Xml in procedures?

不问归期 提交于 2019-11-28 02:01:53
I've asked few people why using xml as a parameter in stored procedure doesn't work and everyone said , that's just the way it is. I can't belive that. command.Parameters.Add("@xmldoc", SqlDbType.Xml); That's where compiler returns error and I can't use NVarChar beacouse it's limiteed to 4k sings. XML would be perfect as it can be 2gigs big. How come other SqlDbTypes work well and this one retruns error ? * Error: Specified argument was out of the range of valid values. Parameter name: @xmldoc: Invalid SqlDbType enumeration value: 25. * Gregory A Beamer It does work. You will have to set up

Profiler for Sql CE

江枫思渺然 提交于 2019-11-27 23:32:56
i wonder if there is something similar to Sql Profiler for Sql Server Compact Edition? i use SqlCE as backend for a desktop application and it would be really great to have something like sql profiler for this embedded database. or at least something simliar to the NHibernate show_sql feature... any ideas? thanks j. Sam Saffron The only tested solution I know of that could solve this problem is Altiris Profiler which is a tool I designed at my previous job, but is closed source and not-for-sale. The way you would hook it in, is by creating a factory for your commands and proxing them for

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

这一生的挚爱 提交于 2019-11-27 23:29:57
问题 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

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

徘徊边缘 提交于 2019-11-27 22:42:06
问题 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