An unhandled exception of type 'System.Data.SqlClient.SqlException

  • Thread starter Thread starter Mark Firth
  • Start date Start date
M

Mark Firth

I get the error on the following line

mvCmd.CommandText = sSql
mvCmd.Connection = mvConn
mvCmd.CommandType = CommandType.Text
Return mvCmd.ExecuteScalar

The sql string is:
sp_TimeSheetAED 'E',86387,'BG004',NULL,13,13,'311',3,'0',0,'25-Mar-2004',2.00,'testing',2..00,2.00000000,72.00,144.00,144.0000,0,0,0.100,0,144.00,NULL,144.00,NULL,0,'','',-1,NULL,NULL,NULL,NULL,NULL
The string work perfectly in Query Analyser.

The same error is produced if I change to a parameterised command

The base message contains Message: "Line 1: Incorrect syntax near 'sp_TimeSheetAED'."

This function is called many times and has been working in multiple apps for 2 years

Ideas will be greatly appreciated...

Mark Firth
 
Mark Firth said:
I get the error on the following line

mvCmd.CommandText = sSql
mvCmd.Connection = mvConn
mvCmd.CommandType = CommandType.Text
Return mvCmd.ExecuteScalar

The sql string is:
sp_TimeSheetAED
'E',86387,'BG004',NULL,13,13,'311',3,'0',0,'25-Mar-2004',2.00,'testi
ng',2.00,2.00000000,72.00,144.00,144.0000,0,0,0.100,0,144.00,NULL,144.
00,NULL,0,'','',-1,NULL,NULL,NULL,NULL,NULL
The string work perfectly in Query Analyser.

The same error is produced if I change to a parameterised command

The base message contains Message: "Line 1: Incorrect syntax near 'sp_TimeSheetAED'."

This function is called many times and has been working in multiple apps for 2 years

Ideas will be greatly appreciated...

That looks like it's a stored procedure, in which case you should set
the command type to CommandType.StoredProcedure.
 
Mark:

If this is a proc, then set the commandtype to CommandType.StoredProcedure
http://www.knowdotnet.com/articles/commandtype.html . This is a pretty
common thing to do. However, you'll want to send in the commandtext with
Parameters for many many reasons so change the commandtype and paramaterize
the query.

HTH,

Bill
I get the error on the following line

mvCmd.CommandText = sSql
mvCmd.Connection = mvConn
mvCmd.CommandType = CommandType.Text
Return mvCmd.ExecuteScalar

The sql string is:
sp_TimeSheetAED
'E',86387,'BG004',NULL,13,13,'311',3,'0',0,'25-Mar-2004',2.00,'testing',2.00
,2.00000000,72.00,144.00,144.0000,0,0,0.100,0,144.00,NULL,144.00,NULL,0,'','
',-1,NULL,NULL,NULL,NULL,NULL
The string work perfectly in Query Analyser.

The same error is produced if I change to a parameterised command

The base message contains Message: "Line 1: Incorrect syntax near
'sp_TimeSheetAED'."

This function is called many times and has been working in multiple apps for
2 years

Ideas will be greatly appreciated...

Mark Firth
 
Bill
I am sending text for debugging purposes, in production I send a parametised
command in production and get the same error
 
Fixed the problem in the parametised query, required the @ReturnValue in the
correct format
 
Back
Top