我收到错误每次单击我的按钮时,对象类型System.Data.DataRowView都没有映射到已知的托管提供者本机类型..这是我的代码..
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
答案 0 :(得分:0)
Borrow.Id需要绑定到ListBox.ValueMember。