How to create an SQL Compact 2008 application - c#

How can I make a SQL Compact 2008 application for the desktop? I know how to connect to a .SDF file with SQL Management Studio 2008, but I can't figure out how to connect to it with my app. I have seen tutorials about this and I can see in the C# code they are referencing some special namespaces, but I can't seem to get it to work. What I did is download the Microsoft SQL Compact SDK but I get an error whenever I try to add references to any of the DLL's that came with it. Does anyone know where I can find the correct binaries for this.

Have you gone here and downloaded all the components listed (including the design tools)?
If you post the "error" you get it might be easier to diagnose your problem.

You need to download SQL Sever Compact 3.5.
Then you could create a LINQ2SQL model (dbml) using the sqlmetal tool that
comes with the .NET SDK (and Visual Studio). Currently it is not possible
to create LINQ2SQL classes for the compact framework inside Visual Studio,
but you will be able to view and edit them.
I haven't got much time now, as I really need to get going,
but I hope this gets you started.
PS: References in my project are System.Data, System.Data.Linq
and System.Data.DataSetExtensions
UPDATE:
As for the DLL's you are referencing... I don't think they are .NET assemblies
but native win32 DLL's intended to be used by C++ developers.

Related

DTS.dll not registering properly in C# ASP.Net Visual Studio 2008 project

I've inherited an application from a former co-worker. It's a C# ASP.Net Web Application. When I try to compile it in Visual Studio 2008, it complains that it can't find the DTS namespace. So I added the DTS.dll file to References from C:\Program Files\Microsoft SQL Server\100\DTS\Binn. When I do that, all compile errors go away, but I get two warnings that look pretty nasty to me:
"Cannot find wrapper assembly for the type library DTSLib. Verify that (1) the COM component is registered correctly and (2) your target platform is the same as the bitness of the COM component. For example, if the COM component is 32-bit, your target platform cannot be 64-bit."
and
"The referenced component DTSLib could not be found"
Also, DTSLib in the References in Solution Explorer has a yellow exclamation point next to it.
First, am I correct to be concerned about this? Second, if so, how do I solve it? It's not a question of the bitness, since I'm working on a 64-bit machine and took the dll from Program Files, not Program Files (x86).
#Melanie: DTS has a some support issues in 2008, due to the creation of SQL Server Integration Services. https://msdn.microsoft.com/en-us/library/bb500440%28v=sql.105%29.aspx?f=255&MSPPError=-2147217396
I hope the support issues have been ironed out if the client is also on SQL Server 2008 R2.
What the most likely problem is is you do not have the packages fully installed. This is rather easy and handled by following the instructions at https://msdn.microsoft.com/en-us/library/ms143755(v=sql.105).aspx - essentially a backward compatibility "hack".
The problem may be the failure to register some COM components, which may or may not exist on drive. Most likely do, as you can follow the instructions above, but they may also be copied and registered at the time.
The reason I asked which version is you would have had to do a repair if they were still on a version like SQL Server 2000.
I would recommend the company invest some time in updating to SSIS, as they are not going to be able to migrate to SQL Server 2012 or 2014 if they still wish to do DTS. It was deprecated in SQL Server 2005, support reduced further in 2008 (with some limitations) and gone as of SQL Server 2012. Actually, there is a hack they might be able to do, but I have not tested it (and do not recommend it, if so).

Visual Studio How to Publish Application that uses data from an Online Database

Hi I published my desktop application on visual studio as a clickOnce installation but I seem to have problems with SQL and Entity Framework Exceptions as this is what my software uses in order to display data. Is there any other way to get around this problem ? Here is an image of what happens when the user wants to see the specific data. Mostly the Exceptions range from both SQL and Entity Frameworks. This only happens upon another computer and not mine which the Software was created on.
Any help would be greatly appreciated !
If you wish to deploy your database with the application binaries then you can try SQL Server Compact instead of the full version of the server, which requires the server to be installed on the machine. The msdn link here will help you with the process -
http://msdn.microsoft.com/en-us/library/aa983326(v=vs.110).aspx
and you can download the application from here -
http://www.microsoft.com/en-us/download/details.aspx?id=17876
In short, SQL Server Compact databases files (.sdf) can be deployed along with your application and some binaries and dlls to help it work on the destination. The msdn topic will show you how to do this.
The full documentation and a good starting point is here too -
http://msdn.microsoft.com/en-us/library/aa983321(v=vs.110).aspx
IMPORTANT Entity framework has some limitations when working SQL Compact Databases, make sure you check and see that this won't be a problem for you.
http://technet.microsoft.com/en-us/library/cc835494(v=sql.110).aspx

Can't use SQL Server CE in VS2012

I'm developing a web application and was trying to use a local database file to store some information. However, when I add the .sdf file, I get an error. Below are some screenshots detailing my problem.
I've been trying to figure what's wrong for several hours. I've seen similar issues, but have yet to find a fix. I used to be able to use SqlServerCe connections before with .sdf files, though that was a different development environment. I have tried reinstalling everything SQL several times, including downloading everything I could find on MSDN. Can anyone help me out?
Below is my Solution Explorer View. I've just added Database1.sdf to the project.
I get an error as soon as I add it:
If I try to open the .sdf file, I get this error:
Here is my list of references:
And, finally, all of the relevant SQL-related installations on my local machine:
SQL Server Compact 4.0 is supported by VS 2012, but requires the DDEX provider to be properly isntalled. Sounds like your VS install is somehow broken. You can install my Toolbox add-in, and go to the About dialog in the Toolbox to check if the DDEX provider and SQL Server CE 4.0 is properly installed.

SQL Server CE distribution

I have spent several days trying to solve this problem with no luck and my requirements are really simple - I want to make an application with database which will work on most PCs (without DB server installed) and I want to use LINQ. For the compatibility reasons I want to use .NET framework 3.5 (every Windows 7 machine has it).
I have tried 2 ways: SQL Server CE and SQLite.
SQL Server CE
Although Visual Studio does not support LINQ for Compact Version of SQL server, I have found simple workaround - generating .dbml file using metal.exe tool from Visual Studio and then dragging it into project. My application works fine on my machine, but when I copy it somewhere else, it crashes. I have copied all dlls from C:\Program Files (x86)\Microsoft SQL Server Compact Edition\3.5 and tried 4.0 too. I think problem is that my app is not looking for dlls (references) inside its directory. I managed to get it work using DataSets (without LINQ), where I manually add reference to SQLServerCE and check CopyLocal to true. BUT when I use LINQ, there is no reference to SQLServerCE in project references and it is working. I don't know how to change it. Or is there a problem somewhere else?
SQLite
After long messing with SQL Server CE, I have tried SQLite. I am very disappointed how poor is SQLite support in .NET. I had to download older version of ADO.NET provider (newer versions does not add SQLite Database into my Visual Studio 2010 - I don't understand why but I googled that it is normal and I have to install old version and then replace it with newer). Then I downloaded dblinq (I have discovered that this project is dead later) and after some messing with dbmetal and dlls I get rid of errors in Visual Studio and compiled my application. But I can't run it, it always crashes on error 40 - like there was no SQLite server. Of course I have copied all dlls. I can't run it even on my development machine.
I am very surprised that it is nearly impossible to create simple database application in C# .NET which will not bother client with servers etc.
Please is there anyone who made SQL CE work with LINQ and mainly who made his app distributable?
I would suggest you try using the nuget Entity Framework for SQL CE package. It will download all the required assemblies to make it work.
http://nuget.org/packages/EntityFramework.SqlServerCompact/

Making a setup for C#/SQL app

this is my first post in stackoverflow, I've always checked this site by searching in google, so I decided to join it myself! I hope to be useful to others
I'm a 3d developer (DirectX), but recently I've started making an SMS gateway using C# and SQL Express, now I'm going to create a setup file for my project (which uses .NET 3.5), what are my options? I've heard that VS 2008 can make setup, is there any sample? how can I include SQL express in my setup app?
also I've downloaded Install Shield 2010 which has a built-in support for VS 2008, I want to make my setup in a way that it detects SQL on target system and if it finds SQL already installed, doesn't try to install it again (the same rule can be applied for .NET), what are my options? how can I make such a setup file?
thanks
With Microsoft's Visual Studio, there is an inbuilt Setup Template which you can use.
Click Once
For your scenario you should take a look at Adding Click once Custom Prerequisites.
Setup And Deployment Application
For your scenario you should take a look at the Walk-through.
Or as you mentioned you have InstallSheild 2010 then:
Install Shield Wizard
Take a look at this Walk-through with Limited Edition
As for SQL Server i think you can usually go as far as SQL Server Compact Edition. (For anything greater you may need to Inform User to install it himself)
I have no personal experience with it, but SQL Server 2008 Compact might be good for this. It is an embedded solution so so you don't actually need to install a server. Alternatively you could look at SQLite, which has native .NET implementations (google for "sqlite .net").

Categories