Newbie: SQL Server connection

  • Thread starter Thread starter steve
  • Start date Start date
S

steve

Hi,

I am dealing with complicated (at least for my standards) created at runtime
Sql queries.
The string construction can get quite complicated and prone to errors
because the possibilities are so many.
I was wondering if there is a way that once you send the query to the server
(dataAdapter) to filter out the response
*before* filling the dataset.
Well, if the SQL server doesnt understand the string I don't think i;ll
reach the filling the dataset point ...!
I am trying to avoid just raising an exception. I would like to warn the
user and allow him/her to reconstruct and resend the querry.


TIA
-steve
 
Yes but the exception can, in principle depend on a few things (server not
available , etc.).
I would like to be able to see if the string is wrong.
 
You will have to examine the exception to see what caused it - it can return
error codes.
 
Hi Steve,

To follow up on Marina's point, you can also print the error message to the
screen with ex.message in the try...catch block. Further, you can actually
run a simple query - say, 'select top 1 from bbb' before running the
complicated query and trap it in a try...catch - if it fails, you have a
connection problem with the database; if it passes in the fill method, you
can set a boolean value and then you know the complicated query is the
problem.

You could also try to run a command like this prior to the complicated
query:
select databasepropertyex('abc','status')
which will return the status of the connection to database abc

HTH,

Bernie Yaeger
 
Thanx both of you.
So i guess there is no better way, I'll have to go around it.
Thanx again!
 
Back
Top