WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Access

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check if Access Table Exists

 Keywords:  Access Table Exists

User Sample Code:

;////////////////////////////////////////////////////////////////////////
;//  WINBATCH - Does Table Exist in ACCESS Database                    //
;//           - Stan Littlefield, December 9, 2001                     //
;////////////////////////////////////////////////////////////////////////
#DefineFunction tblE(DB,tbl)
adSchemaTables = 20
RS             = DB.OpenSchema(adSchemaTables)
lExist         = @FALSE
While ! RS.eof()
   t           = RS.Fields("TABLE_NAME")
   If StrUpper(tbl) == StrUpper( t.Value)
      lExist   = @TRUE
      break
   Endif
   RS.MoveNext()
Endwhile
ObjectClose(RS)
Return(lExist)
#EndFunction


cMDB           = AskFileName("Select ACCESS Database",".\","MDB Files|*.mdb|","*.mdb",1)
cTbl           = AskLine("Look in ACCESS Database %cMDB%","Does This Table Exist","")
cConn          = "Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=%cMDB%"
DB             = ObjectOpen("ADODB.Connection")

DB.Open(cConn)

Ret            = tblE(DB,cTbl)

ObjectClose(DB)
Drop(RS,DB)
If ! Ret
   message("Table DOES NOT Exist",cTbl)
Else
   message("Table EXISTS!",cTbl)
Endif

exit

Article ID:   W15247
File Created: 2002:09:05:13:50:48
Last Updated: 2002:09:05:13:50:48