Click here to Skip to main content
Sign Up to vote bad
good
See more: C#SQL2008.NET4
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 19: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[^]

2 solutions

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  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Christian Graus 544
1 Ron Beyer 296
2 OriginalGriff 258
3 samadhan_kshirsagar 229
4 Sergey Alexandrovich Kryukov 183
0 Sergey Alexandrovich Kryukov 7,007
1 Prasad_Kulkarni 3,815
2 OriginalGriff 3,557
3 _Amy 3,372
4 CPallini 2,975


Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 4 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid