1

我在第四行得到上述错误。我如何(假设我必须)将值转换为双方都具有相同的数据类型?

dsOrderList = objResult.ds
        For Each drow As DataRow In dsOrderList.Tables(0).Rows
            Dim objOrder As New Orders
            objOrder.OrderID = drow("OrderID")
            objOrder.CustomerID = drow("CustomerID")
            objOrder.EmployeeID = drow("EmployeeID")
4

2 回答 2

1

您需要将 dataRow 中的值转换为 int、string 等值,然后再将其分配给另一个变量,其类型可能是 int

于 2013-04-24T09:48:05.433 回答
1

我认为您将一个值串入整数数组,必须有一个数组或提供数组元素

dsOrderList = objResult.ds
    For Each drow As DataRow In dsOrderList.Tables(0).Rows
        Dim objOrder As New Orders
        objOrder.OrderID(0) = drow("OrderID") '0 is Element of Order ID
        objOrder.CustomerID = drow("CustomerID")
        objOrder.EmployeeID = drow("EmployeeID")

或者

dsOrderList = objResult.ds
    For Each drow As DataRow In dsOrderList.Tables(0).Rows
        Dim objOrder As New Orders
        objOrder.OrderID =  {drow("OrderID")}
        objOrder.CustomerID = drow("CustomerID")
        objOrder.EmployeeID = drow("EmployeeID")

更新

如果 objOrder.OrderID 的元素什么都不是,那么使用

objOrder.OrderID = new int() {drow{"OrderID"})
于 2013-04-24T10:22:14.877 回答