Home Forums Programming SMO/RMO/DMO Retreive an error for an UPDATE SQL Statement RE: Retreive an error for an UPDATE SQL Statement

  • Hi

    Thank you for this reply.

    Actually my VB6 program looks that:

    Dim oSQLServer As New SQLDMO.SQLServer

    Dim oDatabase As New SQLDMO.Database

    Dim oTheResults As SQLDMO.QueryResults

    .../...

    Public Function myQuery(r As String) As Integer

    Dim ret As Integer

    Err.Number = 0

    On Error GoTo EndMyQuery

    myQuery = 1 'set error by default

    Set oTheResults = oDatabase.ExecuteWithResults(r)

    myQuery = 0 'ok

    EndMyQuery:

    End Function

    .../...

    req = "UPDATE " + T_LEAFS + " SET leaf_name='" + name2 + "' WHERE leaf_key='" + myKey + "'"

    If (myQuery(req) <> 0) Then SQLError "Rename Node/Leaf"

    'Debug.Print CStr(oTheResults.ROWS)

    oTheResults.ROWS is always equals to 0. Whatever the condition "leaf_key=x" is true or not.

    So I can't know when the UPDATE operation is actually done.

    Do you think the ExecuteWithResultsAndMessages instructions will give me the missing information?

    The last solution could be the use of IF EXISTS (...) instruction

    Thank you