Reputation: 81
I have a program in C# that works with .xls
files, where I query the database as below:
SELECT * FROM [" +sheet + "$]
If the sheet doesn't exist, the program crashes.
I need to first check if the table exists and if so, make some queries.
Is there any such option for OleDbDataAdapter
or SQL
when querying with SELECT
, INSERT
, UPDATE
or DELETE
?
Upvotes: 0
Views: 1829
Reputation: 7451
Use the GetOleDbSchemaTable function. It's a bit obscure, but here's a link or two to some info:
http://support.microsoft.com/kb/318452
Upvotes: 1
Reputation: 26642
You can check shema (tables, views, etc...) via Connection.GetSchema - http://msdn.microsoft.com/en-us/library/ms254934%28v=vs.80%29.aspx
Upvotes: 0