[RESOLVED] SQL Connection testing
hey guys,
i have been working on making this C-Sharp application and it invloves connecting to an SQL Database. is there a way for me to test that the connection has been established? or do i have to just hope it does get connected?
thanks in advance
Re: SQL Connection testing
I'm not sure if I understand... but can't you just run the application?
Re: SQL Connection testing
well i run the application, but until i dont seem to be able to get data sent to the database.. and when i do run the application, it crashes if the button used for submiting data is doing something wrong. generally if it doesnt crash i assume that it is a valid connection but i want to know if i can like run a if statement that will test for the connection(meaning the connection is true or false) and then if it is true i put my data on the database and if it is false i give an error
Re: SQL Connection testing
On developing a db application on my development machine I have NEVER had a database connection attempt go wrong with a good valid connection string/connection code. Once the good code is in place a connection can go wrong for a few reasons when the application is live.
Also as a side note whenever I do an app I purposely don't code any try catch blocks in the beginning so that I can see what exactly is causing the app to crash and more easily see the mistakes I was making. Once I pretty much think I have the code as error free as possible (within reason) I code the try catch blocks.
If you step through your code you should see that most likely your problem is not whether you are connected or not. If you got it right at some point then you probably have it right all the time.