Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO with autonumber PK

Status
Not open for further replies.

Fredde

Programmer
May 10, 2001
22
0
0
SE
I have a problem with an INSERT INTO using ASP connected to Access.The problem is that I get promted
"Index or primary key cannot contain a Null value." when I do the following insert:

INSERT INTO tblHardware(Devicetype) VALUES('something')

Devicetype is not the primary key.

Since I want the primary key to be an autonumber I don't want to insert that number, please help me.

/Fredrik
 
Hi

I know this is asking the obvious but..

I assume you do have the PK column defined in the table, and it is type autonumber ?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Fredrik,

I can't comment on ASP as i've never used it, but normally when i run an INSERT statement via ADO to a Autonumber PK, Access inserts the record and adds the PK itself.

Do you have any other fields in this table, especially "required" fields?

Not very helpful, but it may get you thinking.

Leigh Moore
Solutions 4 MS Office Ltd
 
KenReay: Yes.

leighmoore: Yes. The PK adds automatically in ACCESS. There are reqired fields but since I got the message:
"Index or primary key cannot contain a Null value." I assume that it is that filed that is the problem.

/fredrik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top