I have a program in C开发者_Python百科# 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
?
Use the GetOleDbSchemaTable function. It's a bit obscure, but here's a link or two to some info:
http://www.codeproject.com/Questions/180842/Reading-Excel-sheet-name-with-characters.aspx?display=PrintAll
http://support.microsoft.com/kb/318452
You can check shema (tables, views, etc...) via Connection.GetSchema - http://msdn.microsoft.com/en-us/library/ms254934%28v=vs.80%29.aspx
精彩评论