Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello,

I jave a problem with sql script run.
My script is not running with .Net Windows Application Setup.
I have created Installer class for SQL Script, but my database not attaching.

So, please help me.
How could that possible?

Thank U.
Ankit Agarwal
Software Engineer
Posted
Comments
Orcun Iyigun 4-Jan-13 2:15am    
Since you haven't explained the specific error and provided a code. This can be general but have a look at this following link[^]. A link you may want to compare your code with:
Deploy SQL Server databases easily with an Installer class[^]

 
Share this answer
 
Hi
You can use from bellow class for manage that.

-----------------------------------------------------------------------------------
    public class DBManagement
    {
        public SqlConnection OpenConnection()
        {
            string connectionString = "Data Source = [YourServerName]; Initial Catalog = [YourDatabaseName]; User ID = [YourSqlUserName]; Password = [YourSqlUserPassword]";

            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(connectionString);
                connection.Open();
            }
            catch
            {
                Console.WriteLine("DataBase is not reachable....");
            }

            return connection;

        }

        public DataTable Execute(string queryString)
        {
            SqlConnection connection = OpenConnection();

            SqlCommand query = new SqlCommand(queryString, connection);

            DataTable resultTable = new DataTable();

            SqlDataAdapter adopter = new SqlDataAdapter(query);

            adopter.Fill(resultTable);

            connection.Close();

            return resultTable;
        }
    }
-----------------------------------------------------------------------------------


You can send [youparameter] directly to your methods of this class.

I hope it's helpful.
 
Share this answer
 
v2

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