Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi..
Im getting
An unhandled exception of type 'System.ArgumentException' occurred in microsoft.visualbasic.dll

Additional information: Argument 'Prompt' cannot be converted to type 'String'.
error in Visual Studio 2002 windows application.

VB
If MsgBox("Are you sure Do you want to delete MTR?".ToString(), MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2 + MsgBoxStyle.Question, Me.Text) = MsgBoxResult.Yes Then


        Dim sqlcon As New SqlConnection(BusinessObject.ConnectionString)
        If sqlcon.State = ConnectionState.Closed Then sqlcon.Open()
        'sqlTrans = BusinessLayer.BusinessObject.Connection.BeginTransaction
        sqlTrans = sqlcon.BeginTransaction()
        sqlCmd.Transaction = sqlTrans
        sqlCmd.CommandType = CommandType.Text

        '' updating stock place in barcodebin
        Dim rsBarCode As New ADODB.Recordset()
        rsBarCode.Open("SELECT * FROM BarcodeBin WHERE MTRId='" & Trim(selMTR.Id) & "' AND CalculatedFor IS NOT NULL", con, 2, 3)
        Dim tmpFlg As Boolean = False
        If rsBarCode.EOF = True Then
            '' If any of the MTR item not alloted to OC , can delete MTR
            tmpFlg = True
        End If
        rsBarCode.Close()
        If tmpFlg = True Then
            Dim qry As String = "UPDATE BarcodeBin SET MTRId=NULL, MTRRaised=0, DeBondDate =NULL, DeBondNumber=NULL, StockPlace='B' WHERE MTRId='" & Trim(Me.selMTR.Id) & "'"
            sqlCmd.CommandText = qry
            sqlCmd.ExecuteNonQuery()
        Else
            Exit Sub
        End If

        sqlTrans.Commit()
        MsgBox("MTR : '" & Me.selMTR.MTRNo & "' has been deleted.", MsgBoxStyle.Information, Me.Text)
        ShowingMTR()
        Me.txtReason.Text = ""

    End If
Else
    MsgBox("Please select MTR.", MsgBoxStyle.Information, Me.Text)
    Exit Sub

End If


Getting error when "
sqlCmd.ExecuteNonQuery()
" encounters.

Any help appreciated.


Thank you....

What I have tried:

I referred almost all .net help forum. im not getting any solution. Even i removed Confirmation Yes/No statement from code, still its triggering same error.
Posted
Updated 14-Mar-17 1:00am
v2
Comments
Tomas Takac 14-Mar-17 6:48am    
Are you sure that the error occurs at sqlCmd.ExecuteNonQuery() and not elsewhere? The exception comes from microsoft.visualbasic.dll and that's not where SqlCommand resides. Maybe it's the MsgBox function? Is this why you added the ToString() to there?

VB
If MsgBox("Are you sure Do you want to delete MTR?".ToString(), MsgBoxStyle.YesNo + 

Why are you calling ToString on a constant string value?
 
Share this answer
 
The error message indicates that there is a problem with the Prompt parameter of the MsgBox Function (Visual Basic)[^].

Try something like this:
VB
Dim prompt = "Are you sure Do you want to delete MTR?"
Dim style = MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2 + MsgBoxStyle.Question
Dim response = MsgBox(prompt, style, Me.Text)
If response = MsgBoxResult.Yes Then
' ...
End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900