|
-
Sep 11th, 2008, 03:34 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Bug !
cant seem to spot the bug! Can anyone please?
---------------------------------------------------
Using cmd1 As New SqlCommand(query, MyConn)
cmd1.CommandType = CommandType.StoredProcedure
..................
..................
cmd1.Parameters.Add("@ReturnErrorText", SqlDbType.NVarChar, (100))
cmd1.Parameters("@ReturnErrorText").Direction = ParameterDirection.Output
cmd1.Parameters.Add("@Success", SqlDbType.Int)
cmd1.Parameters("@Success").Direction = ParameterDirection.Output
MyConn.Open()
cmd1.ExecuteNonQuery()
cmd1.Parameters.Clear()
If Not CStr(cmd1.Parameters("@ReturnErrorText").Value) = String.Empty Then 'if there's error messages from stored proc
MessageBox.Show(CStr(cmd1.Parameters("@ReturnErrorText").Value))
MyConn.Close()
Exit Sub
End If
success = CInt(cmd1.Parameters("@Success").Value)
'before clearing the parameters swap the value of @success to see if Commit transaction is executed
cmd1.Parameters.Clear()
If success = 1 Then
MessageBox.Show("New School has been added SUCCESSFULLY.", " Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Using
Last edited by angelica; Sep 11th, 2008 at 10:30 PM.
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it! 
-
Sep 11th, 2008, 03:44 PM
#2
Re: Bug !
As always, you should have told us which line the error occurred on, otherwise we can only guess.
I would assume that it is on the If statement just after this line:
cmd1.Parameters.Clear()
..and if so, the reason for the occurring is pretty easy to work out (just check the help for .Clear).
-
Sep 11th, 2008, 10:29 PM
#3
Thread Starter
Frenzied Member
Re: Bug !
Ok si_the_geek,
Found the bug, a double clear parameters!
thanks
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it! 
-
Sep 12th, 2008, 06:50 AM
#4
Re: Bug !
What does a "double clear parameters" mean?
-
Sep 12th, 2008, 07:09 AM
#5
Re: Bug !
Think it means she had
Code:
cmd1.Parameters.Clear()
placed twice in the code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|