DDE command with sqlComman object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

i try to execute a DDE command with an SQlClientSQLCommen object and i
obtain "syntax error near "Then" ":

dim sql as string

sql = "CREATE TRIGGER myTrigger " & _
"ON MyTable " & _
"AFTER(UPDATE) " & _
"AS " & _
"BEGIN " & _
"SET NOCOUNT ON; " & _
"If UPDATE(Myfield) Then " & _
"BEGIN " & _
"UPDATE MyTable SET MyOtherField=1 WHERE myID IN (SELECT myID from INSERTED)
" & _
"END " & _
"END"

dim oCmd as new sqlClient.SqlCommand(sql,MyConnection)
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()

So, is my syntax incorrect ? (this request works well in a query analyzer)

Best regards,
 
oups,

when i copy / paste the request from a query analyzer to visual studio,
VS add the keyword "then" automatically and change UPDATE to (UPDATE)

forgot my question ;o)
 
Back
Top