In my application i have database connection
but i dont know how to attach my database with application

Front End : C#.Net
Back End : SQL server 2005


I need to create a setup to run my application on another machine ....

Recommended Answers

All 3 Replies

This is a base example of using connection string, but it works:

static string connString = @"Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;";
        private YourMethod()
        {
            using (SqlConnection sqlConn = new SqlConnection(connString))
            {
                sqlConn.Open();
                //do inquieries:
                string sqlQuery = @"SELECT ... FROM ... WHERE";
            }
        }

Use your correc connection string!

Just simply add your database in your setup project in order to include the database during installation.

Use dynamic connection string rather than hard code. Get your connection string from settings file all the time. then you can simply create your setup file and install into client machine. After installation just change the setting file as per the client info (You can find it in installation folder and then open it with any text editor).
For your Database just get a backup and restore it to client machine or make a script.... :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.