Ok, i asked this in the database forum, but everyone thought i was using VB. I am using ASP. Could someone please provide me with some sample code of how to add a new table to a database, and then add some fields?
Printable View
Ok, i asked this in the database forum, but everyone thought i was using VB. I am using ASP. Could someone please provide me with some sample code of how to add a new table to a database, and then add some fields?
assuming you have a object called conn
which is a connection to your db.
The following example creates a new table with two Text fields:
The next example creates a new table with two Text fields, a Date/Time field, and a unique index made up of all three fields:Code:conn.execute "CREATE TABLE FirstTable (FirstName TEXT, LastName TEXT)"
The following example creates a new table with two Text fields and an Integer Number field. The SSN field is the primary key.Code:conn.execute "CREATE TABLE SecondTable (FirstName TEXT, LastName TEXT, DateOfBirth DATETIME, CONSTRAINT MyTableConstraint UNIQUE (FirstName, LastName, DateOfBirth))"
check proper field types based on your databaseCode:conn.execute "CREATE TABLE ThirdTable (FirstName TEXT, LastName TEXT, SSN INTEGER CONSTRAINT MyFieldConstraint PRIMARY KEY)"
if sql server, access, oracle ect,
check to see that the data types match..
Thanks, that is exactly what i was looking for.
One last question, how would i create an Auto Number field?
this MIGHT work
never tested it
use AutoNumber as field type
k, will try that. Again, thanks for the help!