Can .mdf use as embedded database? - c#

I am new to C# and SQL Server databases, so this may be a stupid question but I am confused.
I want to setup an embedded database on a client machine automatically when he installs my application. I know SQL Server Compact Edition is there but there are so many restrictions in SQL Server CE.
Can I use .mdf files as an embedded database? If yes then how can I setup it on client machine automatically? or is there any other option to solve my problem?

I would recommended to use SQLite. It is simpler to deploy. Also, SQL Server Compact appears to be discontinued.
Is SQL Server Compact discontinued from Visual Studio 2013?
You can use SQLite which doesn't require any installation on the client machine.
SQLite depends on the Visual C++ runtime, but you don't need to install it on the client machine. The system.data.sqlite download page contains several "static" packages that already contain the runtime.
All the "static" packages contain either native or mixed-mode assembly
binaries linked statically to the appropriate version of the Visual
C++ runtime. Typically, these packages are used in cases where
customer machines may not have the necessary version of the Visual C++
runtime installed and it cannot be installed due to limited
privileges.
For example, on my machine I am running Windows 8.1 x64 so I went under Precompiled Statically-Linked Binaries for 64-bit Windows (.NET Framework 4.0) and downloaded sqlite-netFx40-static-binary-x64-2010-1.0.90.0.zip.
This binary package contains all the binaries for the x64 version of
the System.Data.SQLite 1.0.90.0 (3.8.2) package. The Visual C++ 2010
SP1 runtime for x64 is statically linked. The .NET Framework 4.0 is
required.
I then unzipped the package and ran test.exe to make sure everything works. Zero installation required.

Related

How to make C# Application without setup Package

I want need for the Winforms application to be installed. For that I am setting Copy Local to true for MY referenced dlls. I build My project and copy all the files in /Bin/Release or /Bin/Debug (as my project settings).
But Problem is I have to installed on the client's machine is the appropriate .Net Framework version.
is there any option to Winforms application to be run on the client's machine without .Net Framework installation. So I can copy in USB Drive and run it any where,
The short answer is No.
However, as you can see from the Microsoft site, if you are using a Microsoft Windows Version that is still supported, you have very good chances of having a Framework Version 3.0 or 3.5 preinstalled and already available.

Connecting to Oracle from ASP.NET

I am on a Windows 8.1 x64 machine and trying to connect to my locally installed Oracle 11g database through an ASP.NET WebForms 4 application that I am running from Visual Studio 2013 and IIS Express.
I downloaded ODP.NET from this NuGet package. But I keep getting the error Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format.
Someone please help me troubleshoot this problem. There so little source code and sample out there regarding Oracle and .NET that is up to date.
This usually happens when referencing an assembly that is either 32-bit from a 64-bit application or the inverse. Please make sure you're WebForm project is targeting the same platform as the referenced Oracle assembly.
Quote from the page you downloaded your Oracle.DataAccess.dll:
Oracle will still need to be installed on the production or development machine in order to connect to Oracle (those libraries are greater than 100MB in size, so it didn't make sense to include them in a NuGet package), but this package will at least allow the project to be successfully built
So now you can only build your code, not run it. To run it you should get: 64-bit ODAC 11.2 Release 5 (11.2.0.3.20) for Windows x64 from this Oracle page: http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html
Your ASP.NET if installed so after your download and install it run command like this:
C:\oracle\product\11.2.0\client_1\odp.net\bin\4> OraProvCfg /action:gac /providerpath:"C:\oracle\product\11.2.0\client_1\odp.net\bin\4\Oracle.DataAccess.dll"
(assuming your install directory will be C:\oracle\product\11.2.0\client_1\)

How to include both versions of SQL Server CE 4.0 Runtime in Install Shield wizard

I need to include both versions of SQL Server CE 4.0 Runtime in my install shield setup application so the user can use the same version of an installer on both system architectures (x86 and x64).
I found a good solution here: https://stackoverflow.com/a/10224981/382011
But this requires to create two diffrent installers for x86 and x64. In my case I need to combine those two into one setup. How can I modify PRQ files from example to achive it?
You could create a single bundled installer, that installs the correct package based on the machine architecture. To do this is quite easy using Burn from Wix, the following SO thread has an example.
After that you can create a single prerequisite file that installs the bundle.
The installation of the corespondent SQL Server CE prerequisite will be handled automatically by the bundle, so you will separate this logic from the main installer.

Deployment of Entity Framework application using SQL server 2012

I made an wpf application on .Net Framework 4.0. It is using entity framework and SQL server 2012 as a database.
Now I want to deploy this machine on another computer. What needs to be installed on that machine. I am assuming that fresh OS has been installed on target machine.
I've already deployed the same application with install shield, here's the list of all needed deps (downloadable for free from microsoft website) from WinXP SP2 to Win8 and works on both x84 | x64
The no need for entity Framework its already in .netFX 4.0
you can also specify the sqlserver configuration parameters using
SQLEXPR_x86_ENU /ACTION=Install /FEATURES=SQLENGINE /INSTANCENAME=SQLEXPRESS /SQLSVCACCOUNT="NT AUTHORITY\SYSTEM" /AGTSVCACCOUNT="NT AUTHORITY\LOCAL Service" /SQLSVCSTARTUPTYPE=Automatic /BROWSERSVCSTARTUPTYPE=Automatic /TCPENABLED=1 /NPENABLED=1 /ADDCURRENTUSERASSQLADMIN
It depends on how you plan to deploy really. Generally, you'll need a copy of SQL Server (full or express edition depending on budget / whether the limitations of express are a problem for your situation).
You will also need to install the .NET framework and any other dependencies (depending of your app). You could use Visual Studio to create an installer, then it will bundle all of the dependencies and make the installation on other machines nice and easy.

SMO not available in .NET 4.0? Or is there an easier way to backup a database from code

We upgraded our application to .NET 4.0 a while ago, and now need to add the ability to backup SQL Server 2008 databases from the app. However, it doesn't seem that SMO is available for .NET 4. Is there a workaround or better way to perform a database backup (note that our backups need to be user initiated over a website, so we cannot schedule them).
Use BACKUP DATABASE?
Otherwise, try these One, Two
You can still reference SMO from a .NET 4.0 application, even with it targeting the .NET 2.0 framework.
If you get the Mixed mode assembly is built against version 'v2.0.50727' of the
runtime and cannot be loaded in the 4.0 runtime without additional
configuration information. exception, installing the latest version of the SQL Server SDK (SQL Server 2008 R2) should fix it, even if the machine is running an older version of SQL Server e.g. 2005.

Categories

Resources