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

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Create Table using ASP - Newbie
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

neerajdeo
Starting Member

USA
33 Posts

Posted - 02 May 2002 :  16:50:32  Show Profile  Visit neerajdeo's Homepage  Send neerajdeo a Yahoo! Message
I have the following create statement

sSQL = "CREATE TABLE NEW_TABLE1 ( "
sSQL = sSQL & "SNo int , "
sSQL = sSQL & "Description varchar(255), "
sSQL = sSQL & "Amount long, "
sSQL = sSQL & "Last_Bill_Total long, "
sSQL = sSQL & "This_Bill_Amount long, "
sSQL = sSQL & "Cumulative long, "
sSQL = sSQL & "Balance long, "
sSQL = sSQL & "Remarks memo, "
sSQL = sSQL & "PRIMARY KEY (SNo))"
oConn.Execute(sSQL)

The above statement works perfectly. I want to make SNo an autonumber. Access 2000 has a autonumber field. How do I tell it via ASP. Also I want to give the 'Amount' feild a default value of 0. How do I do it. I am using IIS 5.0 and Access 2000.

Thanks

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 02 May 2002 :  17:02:40  Show Profile  Send ruirib a Yahoo! Message
You can specify the type as COUNTER or AUTOINCREMENT, whatever pleases you the most...

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

neerajdeo
Starting Member

USA
33 Posts

Posted - 02 May 2002 :  17:10:20  Show Profile  Visit neerajdeo's Homepage  Send neerajdeo a Yahoo! Message
ruirib thx

Lets say I make it AUTOINCREMENT. But if I delete some records and then I insert some new records is the feild guranteed to be unique if AUTOINCREMENT is used. SNo is primary.

Also How do I write it.

sSQL = sSQL & "SNo int AUTOINCREMENT, "

Is the above correct..

Thanks



Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 02 May 2002 :  17:16:01  Show Profile  Send ruirib a Yahoo! Message
quote:

ruirib thx

Lets say I make it AUTOINCREMENT. But if I delete some records and then I insert some new records is the feild guranteed to be unique if AUTOINCREMENT is used. SNo is primary.


This is guaranteed to be unique (that's a property of the AutoIncrement type).
quote:

Also How do I write it.

sSQL = sSQL & "SNo int AUTOINCREMENT, "

Is the above correct?


No it's not correct. It should be :

sSQL = sSQL & "SNo AUTOINCREMENT, "


Regarding the default value for the amount field:


sSQL = sSQL & "Amount long DEFAULT 0, "






-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

neerajdeo
Starting Member

USA
33 Posts

Posted - 02 May 2002 :  17:47:48  Show Profile  Visit neerajdeo's Homepage  Send neerajdeo a Yahoo! Message
Thanks

The autoincrement worked beautifully.

However the DEFAULT 0 did not

I tried this

sSQL = sSQL & "Amount long DEFAULT 0, "

and then

sSQL = sSQL & "Amount long DEFAULT '0', "

both failed. I get a Create Table error..







Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 02 May 2002 :  17:51:25  Show Profile  Send ruirib a Yahoo! Message
What Access version are you using?

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

neerajdeo
Starting Member

USA
33 Posts

Posted - 02 May 2002 :  18:03:27  Show Profile  Visit neerajdeo's Homepage  Send neerajdeo a Yahoo! Message
I am actually running access xp 2002.. but the db is saved in access 2000 format


Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 02 May 2002 :  18:17:18  Show Profile  Send ruirib a Yahoo! Message
That should work for Jet 4.0 Dbs. What is the connection string you are using?

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

neerajdeo
Starting Member

USA
33 Posts

Posted - 02 May 2002 :  18:30:49  Show Profile  Visit neerajdeo's Homepage  Send neerajdeo a Yahoo! Message
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("_private\Tara.mdb"))

Thats my connection string. I guess I will try JET now.. that will involve many changes

Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 02 May 2002 :  18:46:30  Show Profile  Send ruirib a Yahoo! Message
quote:

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("_private\Tara.mdb"))

Thats my connection string. I guess I will try JET now.. that will involve many changes


Try that. DEFAULT is supported by a Jet 4 Extension, so maybe the driver has some influence...

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 2.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07