I have C# application that uses SQL Database (Local). I managed data layer with SQL Server 2014 and SSMS on my computer. That local database has a sync rule with Azure SQL and use Microsoft SQL Data Sync Agent Preview. Now I need these:
1- I need a Setup File for the application. I know how to create Setup Project with VS2013 for a normal client application but this will be different I suppose. This setup file must contain SQL Compact Edition 4.0 and Microsoft SQL Data Sync Agent Preview setup file.
2- During installation, Installer must check whether SQL Server Compact Edition 4.0 is installed on client computer. If not, it should prompt.
3- I have Database Creation Scripts and after installation of SQL Server CE, I need these scripts should run and create database and database objects which application will use.
4- Now comes the tricky part. I need Microsoft SQL Data Sync Agent Preview installed on target computer. Because the client's local database should have the sync rule with Azure. I have no idea how to do that with installation.
Any ideas?
Unfortunately SQL CE is not supported by SQL Data Sync service. SQL Data Sync supports SQL Server 2005 SP2 and above. Please refer to the "system requirements" page of the MSDN documentation: https://msdn.microsoft.com/en-us/library/jj127278.aspx:
SQL Server 2005 SP2.
SQL Data Sync (Preview) works best with SQL Server 2008 R2 and later as support for SQL Database was added to SQL Server Management Studio in SQL Server 2008 R2. If you do not have SQL Server 2008 R2 you can download a free trial from SQL Server 2012 trial or a trial of SQL Server 2008 R2.
SQL Data Sync (Preview) currently supports only SQL Server and SQL Database. Express versions of SQL Server are not supported.
Related
I developed a C# winforms project with SQL Server database.
My boss told me that target machines had Win 7 and Win 8. So I wasn't worried with system requirements so I used LocalDB with .Net Framework 4.5.1.
Now my boss changed his mind and the project needs to be installed on Windows XP machines.
I know that I need to change the .Net Framework to 4.0, and there will be no problem with that BUT is there a easy way to change the database because I'll need to change probably to SQL Server 2008 R2 .....
You'll just need to run the create scripts (that create your database objects and possibly fill in some lookup/system default values into the tables) against a SQL Server 2008 R2 instance and then you're done! :-)
If you're using Entity Framework, you can have it create your database on the new target server instance - either using code-first and migrations, or by generating a SQL script to run to create your tables and everything else needed.
You cannot do a "binary" downgrade - you cannot take your SQL Server 2012 LocalDB files and attach them to a SQL Server 2008 R2 instance
LocalDB is SQL Server Express 2012. So if you were moving to SQL Server 2012 Standard, you could attach the .mdf file to SQL Server 2012.
In your case, it is a downgrade, so you'll have to unload the data and load into the older DB, using DDL scripts, or use a migration tool that exports to an intermediate format. I like Redgate SQL Source Control, as it stores the object definitions in script format, but if you don't have that, you can use SQL Server Management Studio (SSMS) to connect to LocalDB with something like "(localdb)\v11.0" and then script out your objects as best you can.
I have a Windows application that use a SQL Server 2005 Express .mdf file and I have many clients already with that application and the SQL Server 2005 Express versions on they computers.
Now I'm testing in my development machine but with SQL Server 2012 Express and my problem is that when my application wants to attach the .mdf file it changes its version and my Windows application won't work after that.
It is possible to attach a .mdf file without increasing that version?
You can change the compatibility level of your DB.
ALTER DATABASE <dbNmae> SET COMPATIBILITY_LEVEL = 90 -- for SQL SERVER 2005 compatibility
I have a .NET 4.0, SQL Server 2008 application built on VS 2010.
Since more than 10 months I have been working on a project and its completed now. I moved to the next task of creating an installation of the software. Its also done. But now I have a big issue.
My clients already run software running SQL Server 2005 and its installed on their system. However when I was packaging my VS2010 C# application, I deployed it with prerequisite of SQL Server 2008 but now the problem is, when I try to install my application, it asks to uninstall the 2005 and then to install 2008. But my clients are very rigid to allow my program to uninstall any application on their system. I am stuck here.
I also tried to remove it from my prerequisites and the application was successful to install itself but after when I tried to run my application, its unable to access the database.
How I can solve this issue? Is there any way to make application and database both work with SQL Server 2005 or 2008. Or maybe any other expert advice.
EDIT 1
I also have Datetime stuff which really annoyed with to accomplish, as my project is multilingual so I have separate functions to handle datetime to insert in SQL.
EDIT 2
Is it possible to upgrade SQL Server 2005 to 2008 using my own Visual Studio Deployment Project?
EDIT 3
This is the error I am getting
Prerequisite check for system component SQL Server 2008 Express failed with the following error message:
SQL Server 2008 Express Service Pack 1 (x64) cannot upgrade the existing instance of SQL Server 2005 Express (x64 WoW) named 'SQLEXPRESS'. Uninstall this instance of SQL Server 2005 Express and retry installing SQL Server 2008 Express Service Pack 1 (x64)."
See the setup log file located at 'C:\Users\BOOGI~1\AppData\Local\Temp\VSD41A1.tmp\install.log' for more information.
EDIT 4 (Main)
Is it possible to make a Microsoft SQL Server database file compatible to run with both SQL Server 2005 and SQL Server 2008?
It is usually not a problem to run an application against any version of SQL Server. Create the database using Management Studio and you're ready to go.
If you have a setup, you may need to change the prerequisites, so that it works with SQL Server 2005.
You may have to adjust the connection string. In the error message you're providing, it is obvious that the instance name of the SQL Server is "SQLEXPRESS", so you need to add this in your connection string.
Also, it is not a problem to run SQL 2005 Express and 2008 Express side by side.
One thing you can do is install SQL 2005 in your development machine or another machine then migrate your schema's and data from SQL Server 2008 to SQL Server 2005 and get your C# application working again. .NET 4.0 doesn't care which version of SQL server you are connecting to as long as you have the appropriate drivers installed for each appropriate database.
For your datetime create a function in SQL server so that it works in both version. Check out some examples in this link.
Thanks,
Kalagen
I have developed a c# application connected to a SQL Server 2008 database, and I want to make a project install. How can I include my database in the application without having to have SQL Server 2008 installed?
It is not possible. you better use SQL SERVER COMPACT EDITION, if you don't want to install sql server in client's system. Sql Server Compact edition enables you to create a local database that can be accessed without sql server. But using it you will not be able to use your application on networking.
Is there any way to do this?
Update: Sorry, I should have included more information. I am trying to create and connect to a SQL CE database using System.Data.SqlServerCe in C# running on a PC (i.e. not running on a Windows Mobile device).
This code:
string connstr = "Data Source=\"" +
filename + "\";Persist Security Info=False;";
System.Data.SqlServerCe.SqlCeEngine engine = new SqlCeEngine(connstr);
engine.CreateDatabase();
... works fine on any PC that has SQL Server 2005 installed, but fails on any PC that doesn't have it installed. I'm trying to find out if there's any way to get this to work without installed SQL Server 2005 on the machine.
You can do it with Visual Studio - when you add a connection, change the data source from Microsoft SQL Server to Microsoft SQL Server Compact 3.5.
Also, if you mean the actual server - as opposed to the management tools - then SQL Server 2008 Management Studio [Express] can open SQL CE databases directly.
Edit: To create the database in Visual Studio, choose "Local Database" when you go to add a new item. That's a SQLCE database. And in SSMS[E], when you choose the SQL Server Compact option, you can choose "New Database" as an option in the Database File drop-down.
Edit2: In order to have code written against SQL CE run successfully on a vanilla target machine, you will need to install something on it, although not SQL Server 2005. SQL CE is a separate product (download page). It should also appear as a redistributable module in Visual Studio if/when you create an MSI installer for your product.
I assume that what you mean is can you create one with a tool, rather than with code. Studio can create them just by going to the Server Explorer and adding a new connection (you'll get the option to create one).
If you're looking for something a little nicer or something that doesn't require Studio, then Primeworks' Data Port Console is a really nice tool.
EDIT
If you need to create it through code then yes, you can still do this without Server installed. Make sure that you have the SQL CE Redistributable binaries (for the proper 32/64bit) deployed to the target and in a place the app can find them.
See locally at
C:\Program Files (x86)\Microsoft SQL
Server Compact Edition\v3.5
or online.
Just to add to what Aaronaught was saying, to connect to a SQL CE database programmaticaly, you don't either need SQL Server installed. CE runs in proc, and as long as the SqlCE dll's are installed (their part of the framework nowadays) then you should be able to connect to it without any issues.