Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

ERROR: Object must implement IConvertible

  Asked By: Ayden    Date: Jun 16    Category: Asp.net    Views: 1166
  

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

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on ERROR: Object must implement IConvertible Or get search suggestion and latest updates.




Tagged: