Creating a Table |
|
Description |
To create a table in ADO, formulate a SQL statement that creates a table and let ADO execute it. To execute a SQL statement in ADO, call the Execute() method of the Connection class. Its syntax is:
Connection.Execute ExecString, RecordsAffected, Options
In this syntax, the SQL statement that creates the database can be passed as the first argument. The other two arguments are optional.
Examples |
Here is an example that creates a simple table with one column:
Private Sub cmdCreateTable_Click() Dim conDatabase As ADODB.Connection Set conDatabase = CurrentProject.AccessConnection conDatabase.Execute "CREATE TABLE Employees(FirstName Text(50));" End Sub
Here is an example that creates a table with two columns:
Private Sub cmdCreateTable_Click() Dim conDatabase As ADODB.Connection Set conDatabase = CurrentProject.AccessConnection conDatabase.Execute "CREATE TABLE Employees(FirstName Text(50), " & _ " Lastname Text(50));" End Sub
In the same way, you can use any of the examples in the SQL section and pass one to the Execute() method.
|
||
Home | Copyright © 2005-2016, FunctionX, Inc | |
|