Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Add To Database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

leatherlips
Senior Member

USA
1838 Posts

Posted - 31 July 2010 :  11:17:45  Show Profile  Visit leatherlips's Homepage  Reply with Quote
I am working on a mod but I need to be able to add some items to the database. How do you add a new section to the database? Also, how do you add an item that is either a yes or no choice? And for the final question (I think), how do you make several choices from the database available as a dropdown?

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

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 31 July 2010 :  14:47:49  Show Profile  Reply with Quote
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.


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.


[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).


[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.


[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.


[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:


[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).

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:

[ALTER]
MEMBERS
ADD#M_ONLINE#YES/NO#NOT NULL#NO
[END]


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.


[ALTER]
MEMBERS
ADD#M_ONLINE#VARCHAR(1)#NOT NULL#N
[END]


quote:
... how do you make several choices from the database available as a dropdown?


That's best done in the program itself. More flexibility.
Go to Top of Page

leatherlips
Senior Member

USA
1838 Posts

Posted - 31 July 2010 :  19:41:53  Show Profile  Visit leatherlips's Homepage  Reply with Quote
Thanks Carefree for the lesson. I'll have to study it a bit more to figure out how to do what I want to do.

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
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 31 July 2010 :  19:43:27  Show Profile  Reply with Quote
Send me Email and I'll try and help you without posting 400 messages as it's developed.
Go to Top of Page

leatherlips
Senior Member

USA
1838 Posts

Posted - 31 July 2010 :  22:23:50  Show Profile  Visit leatherlips's Homepage  Reply with Quote
Will do once I get what I need organized and thought out.

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
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 01 August 2010 :  04:06:08  Show Profile  Visit HuwR's Homepage  Reply with Quote
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
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 01 August 2010 :  04:13:44  Show Profile  Visit HuwR's Homepage  Reply with Quote
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
Go to Top of Page

leatherlips
Senior Member

USA
1838 Posts

Posted - 02 August 2010 :  19:02:20  Show Profile  Visit leatherlips's Homepage  Reply with Quote
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
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 02 August 2010 :  23:57:28  Show Profile  Reply with Quote
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.


Go to Top of Page

leatherlips
Senior Member

USA
1838 Posts

Posted - 03 August 2010 :  09:50:36  Show Profile  Visit leatherlips's Homepage  Reply with Quote
Thanks. That fixed it.

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
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 03 August 2010 :  09:57:41  Show Profile  Reply with Quote
You're welcome.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.2 seconds. Powered By: Snitz Forums 2000 Version 3.4.07