Question

In my webmethod, i am updating the database. but while debugging the cursor escapes on cmd.ExecuteNonQuery(). my code is,

        If tbl = "All" Then
            cmd = New SqlCommand("update setbool set pos_val='False',valid_rp='False',Pos_save='False'", conn)
            cmd.ExecuteNonQuery()
            Return Nothing
        Else
            cmd = New SqlCommand("update setbool set " & tbl & "='True'", conn)
            cmd.ExecuteNonQuery()
            Return Nothing
        End If

Any suggestion?

Was it helpful?

Solution

I found my own solution.

instead of

        cmd = New SqlCommand("update setbool set pos_val='False',valid_rp='False',Pos_save='False'", conn)
        cmd.ExecuteNonQuery()
        Return Nothing

i changed

            Using cmd1 As New SqlCommand("update setbool set pos_val='False',valid_rp='False',Pos_save='False'")
                cmd1.CommandType = CommandType.Text
                cmd1.Connection = conn
                conn.Open()
                cmd1.ExecuteNonQuery()
                conn.Close()
            End Using
            Return Nothing
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top