Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello sir,
I made a windows application using visual studio 2010, c# 4.0 and sql server 2008. I have already finished my project and testing. Now i want to deploy my project with sql server database so that my client when install my software, installation wizard configure database on local machine, create database, creates all required tables .
So that i need not to install sql server to all my client machine..

Please help me to solve this problem...

What I have tried:

public static string connectionname()
{
string ser = "Data Source=" + System.Environment.MachineName + @"\SQLEXPRESS; Initial Catalog=name of database; integrated security=true";
return ser;
}
Posted
Updated 12-Oct-16 1:26am
Comments
[no name] 12-Oct-16 7:07am    
And the problem you are talking about is...?

1 solution

You have to create a sql query script that contains the code to create your database. Using sql manager express:

0) Connect to your server
1) Right click the database
2) In the context menu, select "Tasks" and then "Generate Scripts"

It will present a wizard form. Just follow the pages and it will eventually generate a script that will create your database, including all (selected) tables, stored procedures, views, and user-defined functions, etc.

Once you have that script, include it in your application solution and simply run the script from your app if the database doesn't already exist. I'll leave the exact details of that part to your awesome google abilities.

FWIW, I googled "c# create a database from a sql script", and something that looks like it might contain the desired info was found in the very first link.
 
Share this answer
 
v2
Comments
ADI@345 12-Oct-16 12:02pm    
I know the concept of generating scripts, actually my requirements is not to generate scripts.. i want my database run on another system without sql server setup installation.. How will I do this.. Pls reply
#realJSOP 12-Oct-16 12:41pm    
Then you have to know the network (IP) address or machine name of the SQL server you want to connect to, and include that address (along with the name of the sql server instance) in your connection string.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900