Author |
Topic |
|
neerajdeo
Starting Member
USA
33 Posts |
Posted - 02 May 2002 : 16:50:32
|
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
|
You can specify the type as COUNTER or AUTOINCREMENT, whatever pleases you the most...
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
|
|
neerajdeo
Starting Member
USA
33 Posts |
Posted - 02 May 2002 : 17:10:20
|
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
|
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 02 May 2002 : 17:16:01
|
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 |
|
|
neerajdeo
Starting Member
USA
33 Posts |
Posted - 02 May 2002 : 17:47:48
|
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..
|
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
neerajdeo
Starting Member
USA
33 Posts |
Posted - 02 May 2002 : 18:03:27
|
I am actually running access xp 2002.. but the db is saved in access 2000 format
|
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 02 May 2002 : 18:17:18
|
That should work for Jet 4.0 Dbs. What is the connection string you are using?
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
|
|
neerajdeo
Starting Member
USA
33 Posts |
Posted - 02 May 2002 : 18:30:49
|
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
|
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 02 May 2002 : 18:46:30
|
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 |
|
|
|
Topic |
|