add new table unless already exists 
Author Message
 add new table unless already exists
Hello,

I want my program to check first to see if a table exists in a database,
and if it already does then go ahead and add records.  If the table does
not exist, I want the program to add the table to the database, add
fields to the table, and then add records.  I'm having trouble writing
the code that tells the program to check to see if the table already
exists.  Can any one give me a pointer?

Thanks in advance,
Darren.



Mon, 15 Oct 2001 03:00:00 GMT
 add new table unless already exists

This code will determine whether or not a
table is in a database by cycling through all
of the table names in a database.

Call:

If Not IsTableInDB("MyTable") Then
    'Append Code
Else
    'Table is already there
End If

************

Private Function IsTableInDB(TableName As String) As Boolean

    Dim iCount as Integer

'Note:  MyDatabase is a Public Database object that has already been set
    With MyDatabase
        For iCount = 0 To .TableDefs.Count -1
            If .TableDefs(iCount).Name = TableName Then
                IsTableInDB = True
                Exit Function
            End If
        Next
    End With

    IsTableInDB = False
End Function

--
Later,
Jody


http://www.visual-statement.com/vb


Quote:
>Hello,

>I want my program to check first to see if a table exists in a database,
>and if it already does then go ahead and add records.  If the table does
>not exist, I want the program to add the table to the database, add
>fields to the table, and then add records.  I'm having trouble writing
>the code that tells the program to check to see if the table already
>exists.  Can any one give me a pointer?

>Thanks in advance,
>Darren.



Tue, 16 Oct 2001 03:00:00 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. Add a new Database field to a already-existing Paradox table at RUNTIME

2. Updating/Adding a new record that already exists in the db

3. How to modified existing field and add new field in existing table for Access database

4. Adding PRIMARY KEY to already existing table's field

5. Adding a new field to an existing table via ADOX

6. How to add new columns to an existing table

7. Add New Table to Existing SQL DB

8. add a new column into the middle of an existing table

9. Adding new column to existing table

10. Adding new Table in existing database

11. Add new tables in existing Replication setup

12. Adding a New Field to an existing Database Table


 
Powered by phpBB® Forum Software