Author |
Topic |
|
leatherlips
Senior Member
USA
1838 Posts |
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 31 July 2010 : 14:47:49
|
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.
The drop command deletes a table (if it exists, command ignored if table not found). All commands must be closed with the End command.
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).
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.
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.
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:
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).
quote: add an item that is either a yes or no choice?
If the database type is Access, you could use field type "Yes/No"
For example:
However, it's not available in most others. So I'd recommend using varchar(1) (1 character length field) and limiting the value in the program itself.
quote: ... how do you make several choices from the database available as a dropdown?
That's best done in the program itself. More flexibility. |
|
|
leatherlips
Senior Member
USA
1838 Posts |
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 31 July 2010 : 19:43:27
|
Send me Email and I'll try and help you without posting 400 messages as it's developed. |
|
|
leatherlips
Senior Member
USA
1838 Posts |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 01 August 2010 : 04:06:08
|
quote: If the database type is Access, you could use field type "Yes/No"
You should stick to the standard field types that the forum uses, it does not use yes/no fields, you should use an int or smallint field and give it values of 1 or 0 to denote true or false |
MVC .net dev/test site | MVC .net running on Raspberry Pi |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 01 August 2010 : 04:13:44
|
here is the official instructions for using dbs files http://forum.snitz.com/forum/topic.asp?TOPIC_ID=25296 some of carefree's instructions are not 100% accurate.
quote: 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
This is not correct, the blank line is not the index, it defines the auto ID field for the table (blank if you don't want an auto id) the third line is where the field definitions start and is nothing to do with indexes or ID fields
quote: To modify existing field values in a table, use the Insert command
The INSERT command adds records to a table it does not modify values
quote: (Note: if the field is a string type, value should be in quotation marks, if numeric, just the number value),
example shows double quotes but should be single quotes |
MVC .net dev/test site | MVC .net running on Raspberry Pi |
|
|
leatherlips
Senior Member
USA
1838 Posts |
Posted - 02 August 2010 : 19:02:20
|
Here is a mock up of what I am trying to do:
My Test MOD 2.0
[CREATE]
TEST_MOD
on#int#NULL#0
grouping#int#NULL#0
style1#int#NULL#DEFAULT
style2#int#NULL#1
style3#int#NULL#1
[END]
I'm trying to create a new table TEST_MOD. In it I want different columns.
The on column will tell the mod to be on or off via an admin panel. The grouping column will tell the mod how to group one of two ways via an admin panel. The style columns will be available in a dropdown via the admin panel. Style1 should be the default choice when style2 and style3 are not selected.
I've tried my code above in a file called dbs_mytestmod.asp and run it but it does not create the table. I get this:
I check my database and the table is not there. Also, if I then drop the table it say's the table does not exist. |
Mangione Magic Forum - The Music of Chuck Mangione
My Mods: Googiespell MOD | Link To Reply MOD | Petition MOD | Contact Page MOD | Share This Topic MOD | MP3 MOD | PageEar MOD | Google Viewer MOD |
Edited by - leatherlips on 02 August 2010 19:06:17 |
|
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 02 August 2010 : 23:57:28
|
You have to use a different word than "on". Since "On" is restricted in the following languages: Jet, MS Access, MS ANSI, MS ODBC, MS SQL Server 2000, MS SQL Server 2005, MS SQL Server 2008, My SQL, OLAP, Oracle, Postgre SQL, Postgre SQL 1992, Postgre SQL 1999, Postgre SQL 2003, Sybase, you're going to experience errors.
|
|
|
leatherlips
Senior Member
USA
1838 Posts |
|
Carefree
Advanced Member
Philippines
4207 Posts |
Posted - 03 August 2010 : 09:57:41
|
You're welcome. |
|
|
|
Topic |
|
|
|