How to bake in the databases from SQL Server to C# - c#

I'm very very new to SQL Server, and I have written a program in Visual Studio using C# that uses a table from a database that I have created using SQL Server Management Studio. But if I try to run my program on another device, it either asks for a version of SQL Server to be installed or it fails to connect to the server because I used the local option to create the said database and therefore, the other device doesn't have the permission to connect to it.
I have read somewhere that I should use in-memory databases so that other devices can run this program without connecting to me or needing SQL Server to be installed? Can I store the database somewhere in the project and tell my program to seek it and load it?
TLDR; how to use the features of SQL Server like database and tables while offline and without the need to connect to any server or even the need to install SQL Server itself if possible.
And sorry for my bad English!

Related

Installing a local SQL database on a FTP server

I have created a local SQL database using SQL Server Management Studio. And a program in C# that have a access to that database.
Now I would like to movemy local database to my FTP server. So i could remotely access my database using SSMS and a program that i have created in C#.
My question is, what do i need to do to transfer my database to a FTP server? Is it even possible to have a SQL database on a FTP server, or does it need to be an sql-specific server? Keep in mind that there is no sql managing software installed on a server yet.

Database application using SQL Server 2008 or any dbms

I'm developing a database application using SQL Server 2008. Since I finished my project and I thought I should see it working on another PC or friend. There is a problem in the database server it wants to connect. I want my app connects to the SQL Server every time it runs on a PC of mine, or any other's without losing any data.
I'm using Microsoft SQL Server 2008 installed. I want to use my app other pc without installing Microsft SQL Server.
If you want to make your database 'portable' you have a few options:
Use a online database service, like Microsoft Azure. You can have one central database which you can use with an internet connection;
Save the database next to the application, something like 'embedded', you can use LocalDB for that. Make sure you copy the database file along with the application.
When you want to run your application on another pc, one way is updating connectionString of DB.

Installing C# Windows Form Application with Database on another system

I have developed a winform application in C#.net and using SQL Server 2008.
My application inserts and updates values into database.
Is it possible to install the application on a another system which doesn't have sql server on it?
Imagine using sql azure. Cloud based sql server. The database is never on the same physically computer. It's all down to the connection string.
With an on premise database you need to make sure the database allows external connections, maybe opening up firewall etc. then make sure the connection string is set correctly on the application to talk to external database.
You can even configure to change the connection string as required pointing at different databases depending on the individual requirements.
Scott
Yes, you can. You can access the DB remotely by referring remote DB server in connection string.
It is possible, if you are looking to run the application on machine that is running on the same Domain as the SQL Server and has privileges to the SQL Server.

Publishing application along with the databse with no need of ms sql on client side c#

I am new here to this forum so mind if I am asking a question already answered somewhere.
I have made an application in windows form, now I want to implement it onto another client PC. I published it and I can install it somewhere else fine, but the problem is that when there is a database involved I just cannot get it to work. I have tried everything I know, I attached the DB with the setup using the setup wizard creator but I cannot get it to work.
My main question is: How can I publish an application successfully, along with its DB and everything in working condition, without installing MS SQL on the client PC, if possible?
Typically, when using SQL Server, you are running in a client-server scenario, and SQL Server is the server portion. The connection string stored in app.config would point to the SQL Server, and the user would never need to know anything more about the database.
If your application is designed to be run outside of the network (i.e. 3rd party), you have a couple of options. First, if you want to use a full version of SQL Server, you can make a client installer and server installer. The server installer would be for setting up the server side (including the installation of SQL Server), and during the client setup, they would need to enter the name of the database server.
If the client has SQL Server Express installed, you can supply the database file, and do a direct connection to it rather than installing it inside SQL. However, if the client does not already have Express installed, this won't work.
Finally, SQL Server Compact Edition is designed for running on the client. You can do a "bin deploy" - that is, copy the SQL CE .dll files with your application, rather than installing the software, and the client can use the supplied database. If you haven't written the application for CE, this would require some rework.
you can also use sqlLite , it just need a bit of modification as it stated by Dave Simione

c# Connecting to a local MDF DB File

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.

Categories

Resources