SQL Statement for AutoNumber Data Type

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
devarishi
Forum Contributor
Posts: 101
Joined: Fri Feb 05, 2010 7:15 pm

SQL Statement for AutoNumber Data Type

Post by devarishi »

Hi,

I have an MS Access Database and the table has 3 columns / fields:

Code: Select all

Field Name   Data Type
SrNo           AutoNumber
Item           Text
Remarks      Text
If I remove the first Field "SrNo" then it works fine. But as I need it and its data type being AutoNumber I canno provide any value for it. So, the following SQL Statement doesn't work if the SrNo field is included or I don't provide any vlaue for it .

Code: Select all

$sql = "insert into MyTbl values" . 
        "('" . $V_Item . "','" .
        $V_Remarks . "');";
Any solution?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: SQL Statement for AutoNumber Data Type

Post by requinix »

You may be able to pass NULL, but if not then you have to specify the list of fields you're inserting.

Code: Select all

INSERT INTO MyTbl (Item, Remarks) VALUES ('$V_Item', '$V_Remarks')
devarishi
Forum Contributor
Posts: 101
Joined: Fri Feb 05, 2010 7:15 pm

Re: SQL Statement for AutoNumber Data Type

Post by devarishi »

tasairis wrote:You may be able to pass NULL, but if not then you have to specify the list of fields you're inserting.

Code: Select all

INSERT INTO MyTbl (Item, Remarks) VALUES ('$V_Item', '$V_Remarks')

I just missed that point! Thanks! It helped!
Post Reply