Option Strict On禁止从'String'到'Integer'的隐式转换

use*_*466 1 sql asp.net datatable

txtAddress.Text = DB.ProfileDataset.Tables("tblCustomers").Rows.Item("Address").toString
Run Code Online (Sandbox Code Playgroud)

上面的代码生成Option Strict On禁止在Item("Address")下从'String'到'Integer'错误的隐式转换 我不知道我做错了什么...

Phi*_*rie 5

DataRowCollection.Item财产需要行索引的整数.

我认为你遵循以下语法:

txtAddress.Text = DB.ProfileDataset.Tables("tblCustomers").Rows(0)("Address").ToString()
Run Code Online (Sandbox Code Playgroud)

编辑

要记住的事情:

original code
    = DB.ProfileDataset.Tables("tblCustomers").Rows.Item("Address").toString
compiler sees
    = DB.ProfileDataset.Tables.Item("tblCustomers").Rows.Item("Address").toString
fixed code
    = DB.ProfileDataset.Tables("tblCustomers").Rows(0)("Address").ToString()
compiler sees
    = DB.ProfileDataset.Tables.Item("tblCustomers").Rows.Item(0).Item("Address").ToString()
Run Code Online (Sandbox Code Playgroud)