Click here to Skip to main content
15,897,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
does anyone know the code to make an code for..:

if the database can't be found then

C#
MessageBox.Show("there is no database..")


doe I have to use the name and location of the database or can i use the connectionstring?
Posted
Updated 23-Apr-12 2:38am
v2

One of the ways: You will have a valid connectionstring. Try to connect to database using that connection string. If application fail to connect then a timeout error would happen. Trap the error and show your message box.
 
Share this answer
 
You can find a code snippet on following link:
check whether database exists[^]
How to check if a database exists in SQL Server[^]

And following article might help you, a good article on cp to
Check if a table or field exists in a database[^]
 
Share this answer
 
v2
Comments
OdeJong 23-Apr-12 9:57am    
Thanks for your solution! I will try to use that article and I think it's going to be o.k. now (Y)
Prasad_Kulkarni 23-Apr-12 12:21pm    
I hope too..
Thank You for accepting solution.
 
Share this answer
 

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