I wasn't getting this error when I was using MX but once I moved over to Visual
Studio I am getting it. My code compiles with no errors but when I try to
deleteing a record I get this error:
System.InvalidCastException: Object must implement IConvertible. My code is
below and the line that it errors out on is in red text. Can someone help me?
Protected Sub MyDataGrid_Delete(ByVal Sender As Object, ByVal E As
DataGridCommandEventArgs)
Dim DeleteCmd As String = "Delete From Users where User_Guid = @UserGuid;"
Dim MyCommand As New SqlCommand(DeleteCmd, MyConnect)
MyCommand.Parameters.Add(New SqlParameter("@UserGuid", DbType.Guid, 16))
MyCommand.Parameters("@UserGuid").Value = _
MyDataGrid.DataKeys(CInt(E.Item.ItemIndex))
MyCommand.Connection.Open()
Try
MyCommand.ExecuteNonQuery()
Message.Text = "Record Deleted"
Message.Style("color") = "Red"
Catch ex As SqlException
Message.Text = "Error"
Message.Style("color") = "Red"
End Try
MyCommand.Connection.Close()
BindGrid()
End Sub