Morgoth
07-25-2002, 04:10 AM
I need the code that will create a new table in a db and also create about 13-15 fields. That I need to be able to rename and change the settings for, like the default value, or number of chars.
All this is done in the code, I don't need a form to do this.
Does anyone know how to do this? Or a site that can teach me?
hi
the typical syntax is as follows. assuming you have a connection object named connObj:
sqlMakeTable = "create table tableName ([field1] integer, [field2] memo with comp, [field3] text (50))"
connObj.Execute (sqlMakeTable)
you can add as many fields as you like, using the same pattern as below:
[fieldName] datatype (length/precision) :D
Morgoth
07-25-2002, 09:37 PM
Thank you ReyN, but would you be able to expand "[fieldName] datatype (length/precision)"
Such as how would I be able to set a default value, or create a primary key. If it wouldn't be a problem for you to expand on it please? And if there is a tutorial you know of that I could look at for more information about this topic, I would love to see it.
Thank you again, ReyN.
okay, here's an excerpt from the JetSql docs:
Syntax
CREATE [TEMPORARY] TABLE table (field1 type [(size)] [NOT NULL] [WITH COMPRESSION | WITH COMP] [index1] [, field2 type [(size)] [NOT NULL] [index2] [, ...]] [, CONSTRAINT multifieldindex [, ...]])
The CREATE TABLE statement has these parts:
table - The name of the table to be created.
field1, field2 - The name of field or fields to be created in the new table. You must create at least one field.
type - The data type of field in the new table.
size - The field size in characters (Text and Binary fields only).
index1, index2 - A CONSTRAINT clause defining a single-field index. For more information on how to create this index, see CONSTRAINT Clause.
multifieldindex - A CONSTRAINT clause defining a multiple-field index. For more information on how to create this index, see CONSTRAINT Clause.
---------------------------------------------------
A CONSTRAINT clause establishes various restrictions on a field, and can be used to establish the primary key. You can also use the CREATE INDEX statement to create a primary key or additional indexes on existing tables.
I don't recall having seen a site devoted to JetSql, but I think one good place to start would be the docs itself, which ships free with the MSOffice 2000 discs. It's available as a help file in html format, just search for JETSQL40.chm :D
Morgoth
07-27-2002, 03:35 PM
You have lost me.
I'm going to go look on the internet, hard core, for about 2 hours an try to pick up something. I'll reply with some information that maybe you can sort out for me.
Thanks.