0

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.

2
  • Could you please share your connection string? Commented Mar 31, 2017 at 3:12
  • You can either back-up and then restore the database, or 'script the database out' (using the tools in SSMS) to avoid re-creating it from scratch if you didn't save the scripts... Commented Mar 31, 2017 at 7:39

2 Answers 2

0

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#

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.