質問

In my application, I get a weird error at multiple locations. Basically, I call a stored procedure in the database using an SqlManager and the executeNonQuery() method but I get an exception saying:

Incorrect syntax near '44444'

in Visual Studio. The thing is, none of my values are equal to '44444' and that string is not in the stored procedure. When I start a trace with the SQL Server Profiler, I do not see the value.

I've tried googling this issue and the only issue that came near this was someone having a similar issue when a null value was putted in a foreign key (none of my values are null).

Function where I call the stored procedure:

Try
    Dim p As New List(Of SQLParametre)()
    p.Add(New SQLParametre("@InvcNum", invcNum, SQLParametreType.String))
    p.Add(New SQLParametre("@Sale", sale, SQLParametreType.Decimal))
    p.Add(New SQLParametre("@Commission", commission, SQLParametreType.Decimal))
    p.Add(New SQLParametre("@UpdtDate", DateTime.Today, SQLParametreType.Date))
    m_Manager.executeNonQuery("TheSP", p)
    Return True
Catch ex As Exception
    m_Log.WriteLog("theSP crashed", ex.Message)
    Return False
End Try

The stored procedure:

ALTER PROCEDURE [dbo].[TheSP]
@InvcNum varchar(9),
@Sale money,
@Commission money,
@UpdtDate as smalldatetime
AS
UPDATE tbInvc SET
  Sale = Sale + @Sale,
  Comm = Comm + @Commission,
  updateDate = @UpdtDate
WHERE (Num = @InvcNum)

Did someone ever get a similar issue where a syntax error was being thrown by a string not in the query/stored procedure?

EDIT: I'm using Visual studio 2012 and SQL Server Management Studio 2012 and fixed a typo in the stored procedure from changing the column's names.

UPDATES

After running the stored procedure in Management Studio, I saw the error appearing there too, so the error should not be in the vb code.

The error thrown by Management Studio is also a different one than the one I get in the exception in VS2012:

Msg 102, Level 15, State 1, Procedure tbInvc_UTrig, Line 14
Incorrect syntax near '44444'.

役に立ちましたか?

解決

As per the comment thread: The issue appears to be with a trigger attached to the table.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top