MSsql query Error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
harrison
Forum Commoner
Posts: 30
Joined: Thu Jun 09, 2005 12:23 am

MSsql query Error

Post 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.
wyred
Forum Commoner
Posts: 86
Joined: Mon Dec 20, 2004 1:59 am
Location: Singapore

Post by wyred »

Would you show us the table structure for "tblosfdtl"?
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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.
Last edited by nigma on Mon Jun 20, 2005 12:54 pm, edited 1 time in total.
User avatar
harrison
Forum Commoner
Posts: 30
Joined: Thu Jun 09, 2005 12:23 am

Post 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.
Post Reply