Page 1 of 1

MSsql query Error

Posted: Sun Jun 19, 2005 10:00 pm
by harrison
When executing the MSSql query below, it spits an error saying
An explicit value for the identity column in table 'tblosfdtl' can only be specified when a column list is used and IDENTITY_INSERT is ON
Here's the query

Code: Select all

// assuming that all variables have values
$query = "INSERT INTO tblosfdtl VALUES (
	$available_id,".$this->so_no.",$itemcode,$formatid,$qty,$sel_price,
	$discount,$amount,0,'".date("m/d/Y")."','')";
Can anyone tell me what's wrong? Thank you.

Posted: Sun Jun 19, 2005 10:35 pm
by wyred
Would you show us the table structure for "tblosfdtl"?

Posted: Mon Jun 20, 2005 12:35 am
by nigma
Please don't ask your question in two different forums. I've deleted your post in PHP - Code since you have a reply to this copy and since it probably belongs here.

Posted: Mon Jun 20, 2005 1:36 am
by harrison
Sorry, chief.

But fortunately I already found the answer to my question.
It seems that specifying the fields before VALUE keyword will solve the problem

Code: Select all

$query = "insert into $tablename ($field1,$field2,$field3) VALUES ($value1,$value2,$value3)";
Thanks anyway.