-- Newbie Warning!! --
Hi Guys,
I was just doing some coding which included checking to see if a SQL database existed and creating one if there wasnt. It took me a long time to debug the following issue I was having with the code...
I discovered that you actually have to wait a short period of time for the SQL Server to create the database before you can open it!! In the end I had to throw in a Thread.Sleep(5000) to give my PC enough time to create the database before using it.
The point of this thread is... are there any other tricks like the one above that people like me should know about when dealing with SQL databases??
Hang on, I'm not finished yet!!The following code checks to see if a database exists. Question, is there a better and cleaner way to do the same thing without relying on a error to happen??!!
Code:Dim sqlDBConn As New SqlConnection Try sqlDBConn = New SqlConnection("Initial Catalog=New_Database; Data Source=localhost; uid=sa") sqlDBConn.Open() Catch ex As Exception ... 'create database code ... End Try
Your help would be greatly appreciated.
soulcode.![]()


The following code checks to see if a database exists. Question, is there a better and cleaner way to do the same thing without relying on a error to happen??!! 
Reply With Quote


