Click here to Skip to main content
12,623,295 members (29,180 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# .NET SQL-Server , +
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 3-Jan-13 20:33pm
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[^]
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161128.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100