Well, you packed a lot into a 2 line query. lol
First, to add a new section to the database. Do you need a new table or new fields in an existing table? That is done using a dbs form. We'll use extracts from the auction mod dbs file for an example.
Code:
Auction Mod Version 2.6
[DROP]
AUCTIONBIDS
[END]
The drop command deletes a table (if it exists, command ignored if table not found). All commands must be closed with the End command.
Code:
[CREATE]
AUCTIONFEEDBACK
AUCTIONID#int#NOT NULL#
BUYERID#int#NULL#
SELLERID#int#NULL#
BUYERSCORE#int#NULL#
SELLERSCORE#int#NULL#
BUYERCOMMENT#varchar(50)#NULL#
SELLERCOMMENT#varchar(50)#NULL#
DATEBUYER#varchar(20)#NULL#
DATESELLER#varchar(20)#NULL#
[END]
The Create command makes a new table. The table title is the second line. A blank line is left if no index field is required, otherwise the third line is the index field's information.
Field definitions follow until the last field is added, then use the End command to close. Definition formats: field title, # sign (separates each part of definition), field format (varchar = text, the length of the text field in parentheses following - limit 255), (int = integer, no field length), (smallint = values 0 to 65535), memo (for text fields that can exceed 255 chars, no field length), # sign, NULL (if null allowed, leave blank or use "NOT NULL" if not), # sign, default value (leave blank if none), # sign (if default value left blank).
Code:
[INSERT]
AUCTIONCATEGORIES
(CATEGORYNAME,CATEGORYDESCRIPTION)#('Motor','All types of Motor vehicles')
[END]
To modify existing field values in a table, use the Insert command. The second line is the table name again, then use as many lines as required in this format:
Opening parenthesis, fieldname, comma, field name, comma, etc., closing parenthesis, # sign, opening parenthesis, value, comma, value, comma, etc., closing parenthesis
Close command with the End command again.
Code:
[DELETE]
CONFIG_NEW
(C_VARIABLE="TPID")
[END]
The Delete command is used to delete records from a database. First line is the command, next, the table, third: opening parenthesis, fieldname,= sign, field value to match (Note: if the field is a string type, value should be in quotation marks, if numeric, just the number value), closing parenthesis. Continue with each record to delete, close with End command.
Use a separate Delete command to delete records from different tables.
Code:
[ALTER]
MEMBERS
DROP#M_REQUIRED###
ADD#M_REQUIRED#VARCHAR(10)##0
[END]
The Alter command is used to add/delete fields from a table. Format:
command, table name, then action lines, and close with End command.
Drop (delete field), # sign, fieldname, ###
Add (add field), # sign, fieldname, # sign, field type (see field definitions above from Create command), # sign, NULL or NOT NULL/blank, # sign, default value or blank, # sign (if default value left blank).
Finally, the Update command:
Code:
[UPDATE]
CONFIG_NEW
C_VALUE#'Ver 2.4.4'#C_VARIABLE='STRIPGATEVER'
[end]
Updates records. Format: command, table name, update lines, close with End command.
Update line format:
Field name, # sign, New Value, # sign, Where clause (specify condition to meet - in this case, "c_Variable" had to equal a string value of STRIPGATEVER).
... how do you make several choices from the database available as a dropdown?
That's best done in the program itself. More flexibility.