vb.net - Insert statements fail when run against SQL Server 2008 -
vb.net - Insert statements fail when run against SQL Server 2008 -
i have deploy vb.net application developed in vb.net , visual studio 2005. client using sql server 2008, while application beingness built against sql server 2000.
i received next error against sql server 2008:
an explicit value identity column in 'outgoing_invoice' table can specified when column list used , identity insert on
here query inserting info in 2 tables:
dim cmd1 new sqlcommand("insert stock values(@invoice_no, @gate_pass, @exp_no, @clm_no, @category, @item_name, @weight, @units_case, 0, 0, @crtns_removed, @pieces_removed, 0, 0, @date_added, @date_removed, @inc_total_price, @out_total_price, @discount, @amount, 'sold', @expiry_date) insert outgoing_invoice values(@invoice_no, @exp_no, @party_name, @party_code, @city, @contact, @category, @item_name, @weight, @units_case, @crtns_issued, @pieces_issued, @crtns_removed, @pieces_removed, 0, 0, @scheme, @unit_price, @out_total_price, @discount, @amount, @date_removed, @expiry_date, @order_booker, @salesman)", con)
the error message shows @ cmd1.executenonquery
. both these tables stock
, outgoing_invoice
have identity column labelled serial before @invoice.
the problem arose when insert tried on sql server 2008. when run against sql server 2000, works expected.
what can possible reason issue , how can resolved?
your insert
query needs specify column names before values
clause otherwise these attempted in column order defined in db (which subject alter - not fixed).
since getting error appears insert
tries insert identity column.
in general - when not inserting all columns, must specify column names. always specify column names best practice.
so - specify column list:
insert atable (col1, col2) values (@val1, @val2)
vb.net sql-server-2008
Comments
Post a Comment