locked
How to see what is in the actual SQL statement RRS feed

  • Question

  • User-1188570427 posted

    Is there a way I can see what is actually being passed when running the code below after adding the parameters?

           Dim sqlstringupdate As String = ""
                    Using conn As New Data.OleDb.OleDbConnection(mainconnection2)
                        sqlstringupdate = "UPDATE tbldeletereason SET delete_status = @delete_status WHERE " + _
                        " main_id = @main_id"
                        Dim cmd As New Data.OleDb.OleDbCommand(sqlstringupdate, conn)
                        cmd.Parameters.AddWithValue("@main_id", delete_main_id)
                        cmd.Parameters.AddWithValue("@delete_status", delete_str_error)
                        conn.Open()
                        cmd.ExecuteNonQuery() : conn.Close()
                    End Using
    Wednesday, December 21, 2011 1:52 PM

Answers

All replies

  • User-1828494216 posted

    Sure, with Debuging.

    Shrani.si

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 21, 2011 1:58 PM
  • User1508394307 posted

    Response.Write("delete_main_id=" & delete_main_id)
    Response.Write("delete_str_error=" & delete_str_error)

    Wednesday, December 21, 2011 2:02 PM
  • User-1199946673 posted

    Is there a way I can see what is actually being passed when running the code below after adding the parameters?

    It doesn't work for a simple reasin. OleDb Parameters are not recognized by their name, but by their position. which means you need to add them in the same order they (first) appear in the command. Althought you named the first parameter in the parametercollection @main_id, you're passing the value delete_main_id to the first parameter, which is @delete_status. The name of the parameters is not important, it could be an empty string also

    So to make this work, you need to change the order of the parameters:

    cmd.Parameters.AddWithValue("the name is really not important", delete_str_error)
    cmd.Parameters.AddWithValue("", delete_main_id)

    Wednesday, December 21, 2011 5:23 PM