• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checking the table already present or not

 
Sanjay Jadhav
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
How will i know that the table which i am creating is allready present in the database of Access.
with best regards,
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may be able to use the DataBasemetadata object to list the tables and then check if it's there. OTOH, you can just create it and see if it throws an exception that the table already exists.
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Bosun's suggestion number 2:
create the table, if an exception is thrown, I assume that it already exists so I truncate it ( delete all rows ) to make sure I'm starting with an empty table.
Jamie
 
tormod eriksen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which exception do you look for? SQLException?
 
Sanjay Jadhav
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
Yes it's work with DatabaseMetaData, using the exception way is somewhat missleading.
with best regards,
Sanjay
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sanjay Jadhav:
Hi..
Yes it's work with DatabaseMetaData, using the exception way is somewhat missleading.
with best regards,
Sanjay

Caution with this method: relying on every user to have the same odbc drivers is even more missleading. Many ODBC drivers (especially with access) come up short when it comes to DatabaseMetaData ( not implemented ), but you can always guarantee that DML/DDL will work with every version.
Unless every user has the same access driver, and you can guarantee that the DatabaseMetaData method is implemented, stick with the exception catching
Jamie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic