No, that's an improper and silly way to check for a table existence.
What exception will you get? Will it be due to the lack of table existance
or due to some other error?
And don't forget that exceptions are for exceptional situations, not for
known situations: in your case, table might or might not exist. And if it
doesn't then this isn't an exception.
The proper way is to use GetSchema method - as (O)enone suggested and if
available or execute a DDL statement - almost each database will let you
query for a table using some sort of query statement.
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development
www.rthand.com
Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
"kimiraikkonen" <(E-Mail Removed)> wrote in message
news:3a1374ba-a2c7-475c-8cd9-(E-Mail Removed)...
On Jan 20, 7:53 pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
> John,
>
> Then I would just create a simple SQL command with
>
> "Select * from MyTable"
>
> Execute that with an executescalar and when I get an error then I know
> that
> the table does not exist.
>
> Cor
Cor's tip is the most basic and comprehensive one. When you call
something from a non-existed database, an error will occur and you
won't be able to access then you can use try-catch or kinda things to
display a custom error message.