Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ExecuteNonQuery() error

Status
Not open for further replies.

ksbrace

Programmer
May 13, 2000
501
US
Hello,
I am trying to implement a delete method in a button click event. I am getting this error msg: [red]Object must implement IConvertible.[/red] There are other Forms in this web app. that have the same exact functionality and I basically copy/pasted the code and just altered the fields. Any help would be greatly appreciated. Thanks in advance!!!
Code:
Me.SqlConnection.Open()

        Dim deleteSucceed As Integer = scDelete.ExecuteNonQuery()

        Me.SqlConnection.Close()
 
scDelete is your commang object? Are you assigning the connection to the command's connection object?

Maybe give a bit more detail
:)

D'Arcy
 
sorry about that, I always worry about pasting too much code in this forum. Anyway, here's what I have for scDelete. It is a command object. Tjanks again.
Code:
''Inside #Region " Web Form Designer Generated Code "
'scDelete
        '
        Me.scDelete.CommandText = "dbo.[usp_datFmea_Details_Delete]"
        Me.scDelete.CommandType = System.Data.CommandType.StoredProcedure
        Me.scDelete.Connection = Me.SqlConnection
        Me.scDelete.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        Me.scDelete.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FmeaID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        Me.scDelete.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UpdateUserID", System.Data.SqlDbType.VarChar, 20))
        Me.scDelete.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UpdateTime", System.Data.SqlDbType.DateTime, 8))
        Me.scDelete.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UpdateUserID", System.Data.SqlDbType.VarChar, 20))
        Me.scDelete.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Conflict_UserName", System.Data.SqlDbType.VarChar, 60, System.Data.ParameterDirection.Output, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
------
 Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        'do something cool

        ' Calls a SQL statement to update the database from the dataset
        Dim lDetail_UpdateUserID As String = viewstate.Item("Detail_UpdateUserID")
        Dim lDetail_UpdateTime As String = viewstate.Item("Detail_UpdateTime")
        Dim tmpFmeaID As String = viewstate.Item("FmeaID")
        Me.scDelete.Parameters.Item("@FmeaID").Value = tmpFmeaID
        Me.scDelete.Parameters.Item("@UpdateUserID").Value = Session("UserID")
        Me.scDelete.Parameters.Item("@Original_UpdateTime").Value = lDetail_UpdateTime
        Me.scDelete.Parameters.Item("@Original_UpdateUserID").Value = lDetail_UpdateUserID


        Me.SqlConnection.Open()

        Dim deleteSucceed As Integer = scDelete.ExecuteNonQuery()

        Me.SqlConnection.Close()

        'If deleteSucceed > 0 Then
        ' Takes the DataGrid row out of editing mode
        'DataList1.EditItemIndex = -1
        'DataList1.ShowFooter = True


        'Else 'update failed
        '   Dim Conflict_UpdateUserID As String = scDelete.Parameters.Item("@Conflict_UserName").Value.ToString()

            'ConAlert_Display = "true"
            'ConAlert_User = Conflict_UpdateUserID.Trim()

        'End If

        ' Refreshes the grid
        'LoadDataList(DataList1, Viewstate.Item("CompID"), Viewstate.Item("FilterLetter"))
    End Sub
 
When you step throgh your code, what line does it bugger up on (try putting in a try/catch block in and step through the code)

More than likely you're trying to cast a value to something, and its not liking it. If you step through you should be able to isolate which parameter its choking at.

D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top