Simple security for SQL Server LocalDB for local Windows application - c#

A simple C# windows form application that uses a local SQL Server LocalDB (.mdf).
I want the end user to install the SQL LocalDB and application and run it in that simple, but also want the DB to be secured with a password (Like the one that is used on SQL Compact (sdf)).
I couldn't find that option in (mdf DBs) without creating a login in the server that should be identical to the one in the connection string! Which is not user friendly!
Need help! thanks :)

Related

C# SQL Server: Application works with database from another pc

I have my application written in C#, it uses a SQL Server database. I have a connection to a database in my C# code, some queries to write/read from database.
Now consider following: if I want to run this app from another PC, this PC has no SQL Server, will this app work? (I assume not) If not then how can this another PC still work with database? Is there a way to programmatically create database on another PC using C# so it has a name I need, columns I need. I created my database using SQL Server Management Studio.
I guess your application works with a local server.
First of all you should check in your application at startup if there is any local mssql server running. If not, you should handle it by installing one programmatically.
Read this answer how to do this if you don't know it.
After that you have to create the database, it's tables, maybe adding user priviliges. Write a SQL script that gets started by a class that starts it.
Read this to see how to start a SQL script in C#
You can do this by setting up SQL server on another machine (server).
Set that servers authentication to SQL Server authentication (requires username and password for that SQL server Management Studio)
Change the connection string in web/App.config from your C# app to use that servers Ip address and Credentails for SQL server

How can I run an application that depends on a SQL database on another machine with SQL Server?

I have created a CRUD application that is running really well. It connects to SQL on the same machine. I want to publish my C# app and install it on another PC does not have SQL.
Is it possible to run it on that PC, without installing SQL Server on it? If so, how do I do this?
Is it possible to run it on that PC?
Without a database your application is "dead".
You have two options.
Install a sql server it this PC.
Connect to a sql server isntalled in another PC.
It's your choice.
If your project is a small one and the database is less than 4GB and you are not going to install SQL Server on every machine and your client do not have access to a Server with SQL Server then you may want to use SQL Server compact
In this case your database would be an single sdf file and you will connect to it using its path on the machine. Then the connection string would be like this:
Data Source=MyData.sdf;Max Database Size=256;Persist Security Info=False;
For more on connection string see this.
Here is the download link

How to make secure local SQL database for C# application

I have a C# application with .NET 3.5 and SQL SERVER 2008 R2.
I want to make a setup project and i want to install each user db while installation.
I use local db when i import database as application file, the database is available and anyone who has access to the laptop os has access to the database. because the local db' s are not for the multiuser scenarios.
how to secure the database file' s from access or being modified? it contains sensitive data for application behave.
Create in sql windows authentication to server authentication
then you can add username and password then you can secure your database

Visual Studio: Sql Server in-project DB

I would like to create a new VisualStudio project with a simple SQL server db, but i want it to be portable, because several people will need to have access to the DB.
So it should be also accessible from a user with password.
The point is that when i create a Local SQL server DB i can't create a new user because it sais You can only create a user with password in a contained DB.
Is there a way to create a Local DB with password or a way to let several user access to the same DB?
Thx
Is there a way to create a Local DB with password
Yes. I'd recommend using Sql Server CE or SqlLite for a database like this. If you're only using Sql Server as a data store on the local machine, Sql Server, even Express Edition, which is still the full Sql Server engine, is usually way overkill for this. The full Sql Server engine really only makes sense when the database engine is the sole, exclusive reason that the machine where it runs exists.
Is there... a way to let several user access to the same DB?
Yes. Install Sql Server on a dedicated database machine, instead of using a Local DB, and set the appropriate connection string and permissions.
Here's the trick: you can't do both, at least not without going through all the same trouble you'd go through setting up a real Sql Server to run on the machine where this will be installed.

application with setup file with out SQL Server database

I have a windows application which is uses SQL Server as its database. For this application I want to create a setup file for other desktops, but I don't want to install SQL Server on each and every client.
Can you please suggest how to create Windows application with local storage setup file without installing any databases or framework libraries?
You can use SQL Server Compact. The database is stored in a file that you carry with the product rather than requiring a database server.
If this is just for "settings" then consider storing it in the user's application data as a simple XML file.
You don't need to install SQL Server on each client - you can simply install it on a central server then all the clients can connect to and use the same instance.
If this is not a good option because each client must have its own storage locally then you can look to use something like SQL Server Compact, which is a very cut down version of SQL Server that doesn't require installation and runs inproc.

Categories