开发者

OleDbDataAdapter: Check table existence?

开发者 https://www.devze.com 2023-03-09 04:45 出处:网络
I have a program in C开发者_Python百科# that works with .xls files, where I query the database as below:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消