Subject Re: to check if a table is exist and create one
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Wed, 18 Oct 2017 10:04:59 -0700
Newsgroups dbase.getting-started

On 10/18/2017 9:33 AM, eric wu wrote:
>
> how to re-write these codes below to a modern object-oriented
> programming codes? And to be able to work with a database alias.
>
>
> 1. to check if a table is exist
> 2. if not, create one.
>
> thanks in advance!
> Eric
>
>         
>     local f
>     f = new file()
>     if not f.exists( "c:\Issu.dbf" )
>        Create Table  "C:\Issu.dbf"  ( Name char(20),  depType char(10) )
>     endif
>     f = null
>    

// untested:
d = new database()
d.databaseName := "BDE Alias Name"
d.active := true

if not d.tableExists( "tablename" )
    cSQL = "create table ..." // full SQL statement
    d.executeSQL( cSQL )
endif
d.active := false
d = null

Ken


--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm