I'm writing windows application which will be used on one computer. I like to do with SQL server, retrieve data with stored procedures, and so...
My question is, what is the difference between SQL server database (in file) and standard db on SQL server, because I don't want to install SQL server on client's PC just for one app. Can be this SQL server DB used with stored procedures, or is there other way?
Thanks.
If you don't want to install a full SQL Server engine on the client machine you could use an embedded database such as SQL Server Compact or SQLite which are designed for those scenarios.
You may want to look at SQL Server Compact, SQL Server Express or something like SQLite. I don't think any of these really offers a way to run a database engine without installing something or requiring something else to be installed (e.g. you could use AttachDbFileName method with SQL Server but this relies on VS/Express to already be there).
Related
Ok so i know I'm fairly new to C# and MVC but I'm trying to use the code first approach of adding items to a database.
Now I have successfully created new entries to the database but when I go to SQL Server i cannot find the database or tables.
So my question is where is this data being stored as I can't see it in SQL Server like my other databases that I manually created?
My ConnectionString is:
Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-Testing-20140809020449.mdf;Initial Catalog=aspnet-Testing-20140809020449;Integrated Security=True
LocalDb is the new server-less version of SQL Server that has similar features as SQL Express. I would describe it as a just-in-time version of SQL Server that is only running when needed.
In order to connect to it usng SQL Server Management Studio, you need to connect using the following connection string (assming SQL Server Version 11/2014 may change to 12 or higher in future versions):
Then you'll have access to the database.
[project_dir]\App_Data\aspnet-Testing-20140809020449.mdf
I have done so for SQL Server, now I was trying to do it SQL Server Compact.
I am unable to make a connection string in SQL Server Compact which has the provision for providing ip/server.
Try Replicating Data to a remote server.
http://msdn.microsoft.com/en-us/library/ms152568(v=sql.105).aspx
SQL Server Compact is just not designed to be used in a network. It's designed as a local-only cache/database store. It was a design decision made by its authors ... if you need something that works for multiple users in a network - use the real SQL Server (Express or any other edition) (by marc_s
It is also considered bad idea to expose SQL server to network - you may want to redesign your application to have service exposing limited functionality to users and calling DB (in this case you can use local SQL compact, but still consider other editions that are more appropriate to general data storage).
If SQL Compact is requirement - replicate data to local file - MSDN:Replicating Data to SQL Server Compact.
For more information on Sql Compact connection strings - Connecting C# to SQL Server Compact database
I have already finished a desktop application using Visual Studio 2010 and SQL Server 2008.
it's working perfectly on my machine (i have a SQL Server 2008 and 2005 ).
the database is local and unchangeable,
i want this application to be run successfully on the machine that doesn't have SQL Server installed.
my Connection string is:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\KBank.mdf;Integrated Security=True;User Instance=True;Connection Timeout=300
I want to know the best and simplest way to make it. thanks
The simplest way would be to create a setup for your application that states SQL Server 2008 as a prerequisite. That's it.
For further help you would have to supply more information on how you use the database in your application and if you have a way to host a public sql server instance to which your application will connect.
If you're using the AttachDbFilename=|DataDirectory|\KBank.mdf;User Instance=True approach, then you have no choice but to install SQL Server Express (and no other edition!) locally on that / every machine that is supposed to use your application.
This approach is severly flawed in my opinion, and it limits your flexibility.
What I'd suggest is to use the real server approach: put your database onto a server (both on your development environment, and in production) and then you have the flexibility of having either a SQL Server instance on every user's machine (if that makes sense), or you can have a centralized server which the clients only connect to (no local database server installed).
If the database is "local and unchangeable" how about the compact edition? That way your clients dont need to install a full sql server instance
I agree with Nick. if you dont want to install SQL Server on the machine then SQL server compact edition would be one of the option. Syntax is pretty similar to SQL Server but it comes with limitations. like you can not have a stored procedures in compact edition and few more.
You might want to visit SQL CE Tutorial as a development resource.
I'm developing a WPF application, which connects MS SQL2008 database remotely.
The app communicates with the database by Linq-to-SQL. pretty handy.
However, because of the slow database server, I'm trying to use local database caching.
"VS2010 > Add Item > Local database cache" wizard could be a solution, but it uses DataSet and SQL Compact(*.sdf).
I found Linq-To-SQL cannot generate classes from the SQL COMPACT edition!
(when I drag tables, error pops up and says 'unsupported data provider')
So, is there any solution to use Linq-to-SQL with local database cache?
or is there any database sync method played with Linq-to-SQL?
If you still want to go the sql compact way, Lightspeed is a linq-to-sql provider that supports a variety of data-sources. it includes mssql compact.
http://www.mindscapehq.com/products/lightspeed
The free version is sufficient for most projects, with an 8 model/class limit.
Ive used it as a linq provider for MySql and Sql Compact before and it's been great.
You can see everything it supports and how it compares to other existing systems like it here:
http://www.mindscapehq.com/products/lightspeed/comparing-lightspeed
the Local Database Cache Wizard only supports SQL Ce on the client side. if you have SQL Express/SQL Server on the client side, you can use Sync Framework still.
see following samples/tutorials using Sync Framework:
Synchronizing SQL Server and SQL Express
Database Sync:SQL Server and SQL Express 2-Tier
nevermind if it mentions SQLExpress, the SQLSyncProvider referenced in the code should work against SQL Express,SQL Server, and SQL Azure
On my development computer I have MS SQL Server/Visual Studio 2005. My program can correctly connect to my local DB and use it. However my other computer (non-dev) does not have MS SQL Server/Visual Studio 2005 and does not connect to the DB. It spits out the following:
"An error has occurrred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. ..." (Error: 26).
Does this mean I have to install SQL Server 2005 on my non-dev computers? Is there any other way?
My connection string is:
"Data Source=.\SQLEXPRESS;AttachDbFilename=\""
+ Directory.GetCurrentDirectory()
+ "\DB.mdf\";Integrated Security=True;User Instance=True";
Your connection string is telling the Sql Server Native Client ADO.NET Provider to attempt to connect to a Sql Server instance named SQLEXPRESS that will manage the database stored in a file DB.mdf. Since your client computer does not have Sql Server Express installed, it's not going to find a database to connect to.
You will need to:
Install Sql Server on the client computer and deploy your database there.
Switch to Sql Server Compact Edition (SqlCE - embedded database) and re-architect your application to use the portable database file (with SqlCE) instead.
Ditch using a robust database engine and switch entirely to ADO.NET DataSets, saving/loading the contents of the DataSet to an Xml file (via WriteXml() and ReadXml()). If the amount of data you are processing is fairly limited in size, DataSets are a good approach to maintaining integrity (via a strongly typed and well-defined schema) and portability.
If you want to run it on that other pc/server you also need to have SQL Server (need to attach your .mdf to it) or SQL Server Express installed.
Another trick would be to change your connection string so that it points out to another pc/server where your database runs on.
Yes, you do need MS-SQL (Express) available on your target computers. Either a local install or a connection to a server.
It is not that difficult to include SQl Express in a Setup.exe (see PreRequisites).
An alternative is to use SQL-CE or Sqlite or (even) MS-Access. They are 'embedded' database engines so that you only need to distribute DLLs.