Solved

C# Interact with MSSQL DB without installing MSSQL Server

Posted on 2011-09-19
4
338 Views
Last Modified: 2012-05-12
Is it possible to use a Windows Forms application to read and write to an MSSQL mdf file without having to install MSSQL Server Express?

We are trying to deploy some software and would like to make the customer experience as smooth and lightweight as possible and having to download SQL can slow down the installation process significantly and having SQL Server running adds extra load to the low powered point of sales computers being used.
0
Comment
Question by:Dragonseer
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
Minh Võ Công earned 250 total points
ID: 36564446
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 250 total points
ID: 36564577
You need SQL Server in order to use a SQL Server database. In order to be able to use the MSSQL file directly, you would have to basically rewrite part of the SQL Server code.

Sql Server Express does not require that much overhead. About 50 Mb when idle. That is less than most applications. And when you think that the main use of a point of sales computer is to run a single application...

Instead of deploying SQL Server Express however, you could use the Compact edition http://www.microsoft.com/download/en/details.aspx?id=17876. It has a smaller footprint (although I cannot say by how much) and has been designed for your type of need.

An alternative would be to use an Access 2003 database. Although it is not as powerful as SQL Server and is a little bit outdated, it is a very potent database. Access is not required to run it, the free JET database engine is sufficient.

The evangelists at Microsoft would tell you about the virtues of Azure for that type of need, but what is your opinion of cloud computing?  :-)
0
 

Author Comment

by:Dragonseer
ID: 36564619
I love cloud computing and have a fair amount of experience with it. I prefer offloading things like SQL databases to the cloud. Things are so much simpler that way.

Unfortunately, for our customers needs, we require a local database.

I've already looked into and implemented Compact.

Now I'm only have one issue with it.
I have an identity column, ID. With MSSQL Express, when I created commands for insertion, I just left out the ID column and it was auto populated which was perfect. However, with Compact it tells me that I need to supply all the columns, including the ID. However, when I do, it says that I'm not allowed to set the ID because its an identity. I can't figure how to solve this conundrum.
0
 

Author Comment

by:Dragonseer
ID: 36564638
Nevermind looks like I figured it out. MSSQL Express will accept:
 
"INSERT INTO Customers VALUES(@valueA, @valueB, @valueC, @valueD)", connection);

Open in new window


But MSSQL Compact wants:
"INSERT INTO Customers(column2, column3, column4, column5) VALUES(@firstName, @lastName, @phone, @credits)", connection);

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question