Im getting an error No mapping exists from object type System.Data.DataRowView to a known managed provider native type every time i click my button.. here's my code..
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim insertCommand = <xml>
INSERT INTO returns(
Department,
Purpose,
Item_details,
Requested_by,
Approved_by,
ReturnDate
)
SELECT
Department,
Purpose,
Items_Details,
Requested_by,
Approved_by,
Date
FROM borrow
WHERE ID = @BorrowID;
</xml>
Dim param = cmd.CreateParameter()开发者_高级运维
param.ParameterName = "@BorrowID"
param.Value = ListBox1.SelectedValue
cmd.CommandText = insertCommand.Value
cmd.Parameters.Add(param)
cmd.Connection = con
Try
con.Open()
cmd.ExecuteNonQuery()
Catch SqlExceptionErr As Exception
MsgBox(SqlExceptionErr.ToString)
Finally
con.Close()
End Try
End Sub
Borrow.Id needs to be bound to your ListBox.ValueMember.
精彩评论