Hi, I have yet another VB question (I am a noob!). Here is my code:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim Equip As DataRowView = ListBox1.SelectedValue
        Dim Equip_Delete As String = Equip.DataView.ToString
        cmd = New SqlCeCommand("DELETE FROM Sensor_Table WHERE Equipment_ID = @Equip", con)
        cmd.Parameters.Add(cmd.CreateParameter).ParameterName = "@Equip"
        cmd.Parameters.Item("@Equip").Value = Equip
        If con.State = ConnectionState.Closed Then con.Open()
    Catch ex As Exception
    End Try
End Sub

I am trying to delete a row in my table (Sensor_Table) which is bound to ListBox1. The MessageBox is there for debugging purposes. The value shown in the message box is System.Data.DataRowView, not the selected value in ListBox1. I also get the error after the message box: No mapping exists from DbType System.Data.DataRowView to a known SqlCeType. Can someone please advise? Thanks

Edited 4 Years Ago by Thomas7399

You may use indexer method of DataRowView to obtain selected column value.

Dim Equip As DataRowView = ListBox1.SelectedValue
Dim val1=Equip(0) 'Returns value from 1st column
This question has already been answered. Start a new discussion instead.