Regarding SQL Database
-
Dear All, I know this section is regarding C# only,but I am entering regarding SQL Database. I am really sorry for this. I want to Delete the SQL Database programmatically (using C#). I am using following code for Deleting Database. ---------------------------------------------------------- private void DeleteDatabase() { try { String conn = "server="+ strLocalIP +";database="+ "master" +";password="+ "sa" +";User id="+ "sa" +";"; SqlConnection sqc = new SqlConnection(conn); sqc.Open(); SqlCommand sc = new SqlCommand(); sc.Connection = sqc; sc.CommandText = "DROP DATABASE "+strDatabaseName; sc.ExecuteNonQuery(); sqc.close(); } ------------------------------------------------------------------- strLocalIP id computers IP Through Query Analyzer 'DROP Database' is working fine but programmatically it's giving exception, 'connection is in use' :) With Regards Manoj
-
Dear All, I know this section is regarding C# only,but I am entering regarding SQL Database. I am really sorry for this. I want to Delete the SQL Database programmatically (using C#). I am using following code for Deleting Database. ---------------------------------------------------------- private void DeleteDatabase() { try { String conn = "server="+ strLocalIP +";database="+ "master" +";password="+ "sa" +";User id="+ "sa" +";"; SqlConnection sqc = new SqlConnection(conn); sqc.Open(); SqlCommand sc = new SqlCommand(); sc.Connection = sqc; sc.CommandText = "DROP DATABASE "+strDatabaseName; sc.ExecuteNonQuery(); sqc.close(); } ------------------------------------------------------------------- strLocalIP id computers IP Through Query Analyzer 'DROP Database' is working fine but programmatically it's giving exception, 'connection is in use' :) With Regards Manoj
-
Dear All, I know this section is regarding C# only,but I am entering regarding SQL Database. I am really sorry for this. I want to Delete the SQL Database programmatically (using C#). I am using following code for Deleting Database. ---------------------------------------------------------- private void DeleteDatabase() { try { String conn = "server="+ strLocalIP +";database="+ "master" +";password="+ "sa" +";User id="+ "sa" +";"; SqlConnection sqc = new SqlConnection(conn); sqc.Open(); SqlCommand sc = new SqlCommand(); sc.Connection = sqc; sc.CommandText = "DROP DATABASE "+strDatabaseName; sc.ExecuteNonQuery(); sqc.close(); } ------------------------------------------------------------------- strLocalIP id computers IP Through Query Analyzer 'DROP Database' is working fine but programmatically it's giving exception, 'connection is in use' :) With Regards Manoj
-
Connection is in use or database is in use???Normally, when you want to delete a database, you need to disconnect all current connections.
Dear Johny Ng, Even after disconnecting all the connections related with Database it's still giving same exception. Some one has suggested me to flush the connection pool, Please let me know How i can flush connection pool in C#. :) Thanks & Regards Manoj
-
Dear Colin Angus, The conn String is is the connection String containg computer information in which Database exists , Database name, user and password through which i can login to database. String conn = "server="+ strLocalIP +";database="+ "master" +";password="+ "sa" +";User id="+ "sa" +";"; strLocalIP is actually is the IP of computer inwhich Database exists. And sc is sqlcommand through which I execute the sql query. Some one has suggested me to flush the connection pool. Please let me know How i can flush connection pool through C#. :) Thanks & Regards Manoj Kumar
-
Dear Johny Ng, Even after disconnecting all the connections related with Database it's still giving same exception. Some one has suggested me to flush the connection pool, Please let me know How i can flush connection pool in C#. :) Thanks & Regards Manoj
-
Dear Colin Angus, The conn String is is the connection String containg computer information in which Database exists , Database name, user and password through which i can login to database. String conn = "server="+ strLocalIP +";database="+ "master" +";password="+ "sa" +";User id="+ "sa" +";"; strLocalIP is actually is the IP of computer inwhich Database exists. And sc is sqlcommand through which I execute the sql query. Some one has suggested me to flush the connection pool. Please let me know How i can flush connection pool through C#. :) Thanks & Regards Manoj Kumar