|
-
October 27th, 2004, 06:04 PM
#1
Auto numbering in ADO
Hi,
I am new to database programing and have this problem I can't find an answer to. This is the code I am using.
[CODE]
Set conData = New ADODB.Connection
conData.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\data.mdb"
strSQL = "CREATE TABLE League (" & _
"ID Integer NOT NULL IDENTITY(1,1) PRIMARY KEY," & _
"LeagueName Varchar(50)," & _
"BowlingCenter Varchar(50));"
conData.Execute strSQL
Set conData = Nothing
[CODE]
However when I add data the ID (primary key) does not increment. All my ID's are 1.
What am I doing wrong?
Thanks for your help.
Wayne
-
October 28th, 2004, 02:45 AM
#2
Re: Auto numbering in ADO
IDENTITY is called COUNTER in access:
use something like :
Code:
Create table ABC(MyID COUNTER primary key )
-
October 28th, 2004, 07:05 AM
#3
Re: Auto numbering in ADO
I already tried that but didn't work. I get a sql syntax error. I found out that if I made the primary key a long then it worked. Don't know why but it does.
Thanks for your reply,
Wayne
Last edited by WayneS; October 28th, 2004 at 07:08 AM.
-
October 28th, 2004, 12:04 PM
#4
Re: Auto numbering in ADO
Hi
this works great in Access XP:
Code:
CREATE TABLE League (ID counter PRIMARY KEY,
LeagueName Text,
BowlingCenter Text)
What version of access do you use ?
Do you get any Error messages ?
-
October 28th, 2004, 05:39 PM
#5
Re: Auto numbering in ADO
The problem is I don't have Access. Wish I did. Had to do it all with ADO and SQL.
Thanks anyway,
Wayne
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|