VP-ASP :: Shopping Cart Software

Shopping Cart Software Solutions for anywhere in the World

US/Canada(Toll Free): +1 888 587 2278
Europe/UK: +44 (020) 7193 9408
Australia/New Zealand: +61 3 9016 4497

VP-ASP Shopping Cart Customer Forum

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

 All Forums
 VPCart Forum
 Customization
 how to add table to database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

BILLCAT
Starting Member

USA
40 Posts

Posted - December 21 2005 :  23:13:13  Show Profile  Visit BILLCAT's Homepage  Reply with Quote
Does anyone know how to add tbles to an access database.

I am using VPASP 5.5
I have an access database

The tables I need to add are shown below with the required fields. Do I need MS Access to do it?

create 2 tables in the database.

1. FAQ_category
FAQ_category has 2 fields.

field name - data type
------------------------
ID - autonumber
catname - text

2. FAQ_Faq
FAQ_Faq has 7 fields.

field name - data type
------------------------
ID - autonumber
faqnumber- Number
faqtitle- text
faq- memo
active - number
faq_question - memo
cat_id - number



Thanks in advanced for your time
Bill

rustytec
VP-ASP New User

Australia
113 Posts

Posted - December 22 2005 :  06:19:16  Show Profile  Reply with Quote
Hi Bill,

The following code will create the table/fields. Just modify the database location and tName, fields as require. (I'v done the first one for you) :)


<% 
    'db = Server.MapPath("import/new.mdb")
	db="c:\import\new.mdb"	 
    
    'if you have JET installed:  
    dbCreate = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & db 
 
    'otherwise: 
    'dbCreate = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & db 
 
    set cat = CreateObject("ADOX.Catalog") 
    set conn = CreateObject("ADODB.Connection") 
    conn.open dbCreate 
 
    cat.activeConnection = conn 
    tableExists = false 
	
    tName = "FAQ_category" 
	
    for i=0 to cat.tables.count-1 
        typ = cat.tables(i).type 
        nam = cat.tables(i).name 
        If typ = "TABLE" and lcase(nam) = lcase(tName) then 
            tableExists = true 
        End if 
    Next 
 	
    if not tableExists then 
		tableCreate = "CREATE TABLE " & tName & "(ID AUTOINCREMENT, Catname VARCHAR(50) )" 
		
		'other field types........
		'IDColumn AUTOINCREMENT
		'IntegerColumn INT
		'VarcharColumn VARCHAR(50)
		'MemoColumn MEMO 
			
        conn.execute tableCreate, , 129 
		
		response.Write("Tables appended to " & tName)
		response.Write ("<br>")
    end if 
	
    conn.close 
    set conn = nothing 
    set cat = nothing 
	
	response.Write("<br>")
	response.Write("Completed....!")

%>




You can simply copy and paste the code to make a new asp file, upload it to your web and open the page in your browser, it runs and presto table/fields made.

Repeat for additional tables and fields etc

Hope this helps

rustytec



Russ
Go to Top of Page

BILLCAT
Starting Member

USA
40 Posts

Posted - December 22 2005 :  14:49:35  Show Profile  Visit BILLCAT's Homepage  Reply with Quote
Rustytec,

WOW, and thanks


Sometimes you feel so frsutrated , and then comes someone like you, Thanks for taking the time . That is why I love this forum.
Go to Top of Page

rustytec
VP-ASP New User

Australia
113 Posts

Posted - December 22 2005 :  15:33:08  Show Profile  Reply with Quote
quote:
Originally posted by BILLCAT

Rustytec,

WOW, and thanks


Sometimes you feel so frsutrated , and then comes someone like you, Thanks for taking the time . That is why I love this forum.




You are very welcome.

This forum and vp-asp is the best and I am more than happy to help when I can.

cheers

rustytec

Russ
Go to Top of Page

BILLCAT
Starting Member

USA
40 Posts

Posted - December 22 2005 :  16:22:10  Show Profile  Visit BILLCAT's Homepage  Reply with Quote
Do you know what this means

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x274 Thread 0x16d4 DBC 0x187b024 Jet'.
/addtodb.asp, line 13


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)

Page:
GET /addtodb.asp



i entered the path to my database and database name. Whe i run the script it shows this.

Thanks
bill
Go to Top of Page

rustytec
VP-ASP New User

Australia
113 Posts

Posted - December 22 2005 :  16:45:24  Show Profile  Reply with Quote
Bill,

Please email me your code so I can check it, rather than posting it in the forum for safety.

My email address is in my profile.

regards

rustytec

Russ
Go to Top of Page

rustytec
VP-ASP New User

Australia
113 Posts

Posted - December 22 2005 :  18:32:17  Show Profile  Reply with Quote
Hi Bill,

I have sent you a zip with two new files that is a better way of doing it. (I simply mod the vp-asp way).

cheers

rustytec


Russ
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000