Incorrect syntax near '('.

  • Thread starter Thread starter Carl
  • Start date Start date
C

Carl

Can you tell me what is wrong with this syntax ?


string select = "UPDATE [PME].[dbo].[Expense] " +
"([ID],[ClientID],[Total],[TPS],[TVQ],[Gtotal],[DateFAC],
[DatePAY],[Description],[fl_type],[fl_status],
[fl_category],[fl_source],[defaut], [Cheque],
[fl_taxable], [notaxe], [id]) " +
" VALUES
(@id,@clientid,@total,@tps,@tvq,@gtotal,@datefac,@datepay,
@description,@fltype,@flstatus,@flcategory,@flsource,@defa
ut,@cheque,@fltaxable,@notaxe,@id) " +
" WHERE id = @id";

I receive the following error,

Additional information:
System.Web.Services.Protocols.SoapException: Server was
unable to process request. --->
System.Data.SqlClient.SqlException: Line 1: Incorrect
syntax near '('.
at System.Data.SqlClient.SqlCommand.ExecuteReader
(CommandBehavior cmdBehavior, RunBehavior runBehavior,
Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at WS_PME.DB.SqlGenericExecute(String sqlquery, String
tablename, String ConfigConnectionKey, String fonction,
Object[,] aParameter) in F:\Structure\Projets\VS2003
\PME\WS_PME\Components\DB_dataset.cs:line 181
at WS_PME.DB.Update_Expense(String vClientID, Decimal
vTotal, Decimal vTPS, Decimal vTVQ, Decimal vGtotal,
DateTime vDateFac, DateTime vDatePay, String
vDescription, Int32 vFlType, Int32 vFlStatus, Int32
vFlCategory, Int32 vFlSource, Boolean vDEFAUT, String
vCheque, Int32 vTAXABLE, Decimal vNoTaxe, Guid vID) in
F:\Structure\Projets\VS2003
\PME\WS_PME\Components\DB_dataset.cs:line 298
at WS_PME.WSPME.UpdateExpense(String vClientID,
Decimal vTotal, Decimal vTPS, Decimal vTVQ, Decimal
vGtotal, DateTime vDateFac, DateTime vDatePay, String
vDescription, Int32 vFlType, Int32 vFlStatus, Int32
vFlCategory, Int32 vFlSource, Boolean vDEFAUT, String
vCHEQUE, Int32 vTAXABLE, Decimal vNoTaxe, Guid vID) in
F:\Structure\Projets\VS2003\PME\WS_PME\PME.asmx.cs:line 99
--- End of inner exception stack trace ---
 
try instead:

string update = "UPDATE [PME].[dbo].[Expense] " +
"SET [ID] = @id, [ClientID] = @clientid, " + (etc!)
"WHERE id = @id";

Regards,
Matt


string select = "UPDATE [PME].[dbo].[Expense] " +
"([ID],[ClientID],[Total],[TPS],[TVQ],[Gtotal],[DateFAC],
[DatePAY],[Description],[fl_type],[fl_status],
[fl_category],[fl_source],[defaut], [Cheque],
[fl_taxable], [notaxe], [id]) " +
" VALUES
(@id,@clientid,@total,@tps,@tvq,@gtotal,@datefac,@datepay,
@description,@fltype,@flstatus,@flcategory,@flsource,@defa
ut,@cheque,@fltaxable,@notaxe,@id) " +
" WHERE id = @id";


Carl said:
Can you tell me what is wrong with this syntax ?


string select = "UPDATE [PME].[dbo].[Expense] " +
"([ID],[ClientID],[Total],[TPS],[TVQ],[Gtotal],[DateFAC],
[DatePAY],[Description],[fl_type],[fl_status],
[fl_category],[fl_source],[defaut], [Cheque],
[fl_taxable], [notaxe], [id]) " +
" VALUES
(@id,@clientid,@total,@tps,@tvq,@gtotal,@datefac,@datepay,
@description,@fltype,@flstatus,@flcategory,@flsource,@defa
ut,@cheque,@fltaxable,@notaxe,@id) " +
" WHERE id = @id";

I receive the following error,

Additional information:
System.Web.Services.Protocols.SoapException: Server was
unable to process request. --->
System.Data.SqlClient.SqlException: Line 1: Incorrect
syntax near '('.
at System.Data.SqlClient.SqlCommand.ExecuteReader
(CommandBehavior cmdBehavior, RunBehavior runBehavior,
Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at WS_PME.DB.SqlGenericExecute(String sqlquery, String
tablename, String ConfigConnectionKey, String fonction,
Object[,] aParameter) in F:\Structure\Projets\VS2003
\PME\WS_PME\Components\DB_dataset.cs:line 181
at WS_PME.DB.Update_Expense(String vClientID, Decimal
vTotal, Decimal vTPS, Decimal vTVQ, Decimal vGtotal,
DateTime vDateFac, DateTime vDatePay, String
vDescription, Int32 vFlType, Int32 vFlStatus, Int32
vFlCategory, Int32 vFlSource, Boolean vDEFAUT, String
vCheque, Int32 vTAXABLE, Decimal vNoTaxe, Guid vID) in
F:\Structure\Projets\VS2003
\PME\WS_PME\Components\DB_dataset.cs:line 298
at WS_PME.WSPME.UpdateExpense(String vClientID,
Decimal vTotal, Decimal vTPS, Decimal vTVQ, Decimal
vGtotal, DateTime vDateFac, DateTime vDatePay, String
vDescription, Int32 vFlType, Int32 vFlStatus, Int32
vFlCategory, Int32 vFlSource, Boolean vDEFAUT, String
vCHEQUE, Int32 vTAXABLE, Decimal vNoTaxe, Guid vID) in
F:\Structure\Projets\VS2003\PME\WS_PME\PME.asmx.cs:line 99
--- End of inner exception stack trace ---
 
Can you tell me what is wrong with this syntax ?

string select = "UPDATE [PME].[dbo].[Expense] " +
"([ID],[ClientID],[Total],[TPS],[TVQ],[Gtotal],[DateFAC],
[DatePAY],[Description],[fl_type],[fl_status],
[fl_category],[fl_source],[defaut], [Cheque],
[fl_taxable], [notaxe], [id]) " +
" VALUES
(@id,@clientid,@total,@tps,@tvq,@gtotal,@datefac,@datepay,
@description,@fltype,@flstatus,@flcategory,@flsource,@defa
ut,@cheque,@fltaxable,@notaxe,@id) " +
" WHERE id = @id";

Carl,

Are you trying to do an UPDATE or INSERT? The command you've written
appears to be a strange combination of both. Is this command being
sent to an SQL server, or some other kind of database?


Chris.
 
Hello,

You are using wrong SQL syntax. I assume that this is an update, although
you've mixed the UPDATE and INSERT syntax.

It should be:
UPDATE yourTable
SET
column1 = 'value1',
column2 = 'value2'
WHERE
id = @id

column1 and column2 are examples of column names, you should substitute this
to your column names (i was lazy writing...)

Hope this helps

--
Regards,
Kristofer Gafvert
http://www.ilopia.com - FAQ & Tutorials for Windows Server 2003, and SQL
Server 2000
Reply to newsgroup only. Remove NEWS if you must reply by email, but please
do not.
 
The issue as been fixes using the following syntax,

string select = "UPDATE Expense " +
"SET ID = @id,ClientID = clientid,Total = @total,TPS =
@tps,TVQ = @tvq,Gtotal = @gtotal,DateFAC = @datefac," +
"DatePAY = @datepay,Description = @description,fl_type =
@fltype,fl_status = @flstatus,fl_category = @flcategory,"
+
"fl_source = @flsource,defaut = @defaut,Cheque = @cheque,
fl_taxable = @fltaxable,notaxe = @notaxe " +
"WHERE id = @id";

Thanks for all the answers...

Carl,
 
Back
Top