Page 1 of 1

SQL Statement for AutoNumber Data Type

Posted: Thu Mar 04, 2010 5:45 pm
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?

Re: SQL Statement for AutoNumber Data Type

Posted: Thu Mar 04, 2010 6:05 pm
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')

Re: SQL Statement for AutoNumber Data Type

Posted: Fri Mar 05, 2010 3:49 pm
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!