D
Duane Roelands
I'm having a frustrating problem with some simple code. Isn't that
always the case?
Here's the code in question...
Public Sub GetAllEmployees()
Dim tbl As DataTable = EmpDataSet.Tables(0)
Dim Row As DataRow
Dim MyString As String
For Each Row In tbl.Rows
Debug.WriteLine(Row(0)) '' This line builds fine
MyString = Row(0) '' This line does not build
Next
End Sub
The IDE won't build this code, and mousing over the little squigglies
gives me "Option Strict On disallows implicit conversions from
'System.Object' to 'String'".
If I comment out the "MyString" line, the code builds and runs as you
would expect. This code follows just about every example I've seen of
looping through the rows in a datatable.
Now, I know that I can change the "MyString" line to this...
MyString = CStr(Row(0))
....and it will build and run fine, but I'm not sure why I should have
to do that, or why none of the examples that I'm seeing require such
an explicit conversion.
Thanks in advance.
Duane
always the case?
Here's the code in question...
Public Sub GetAllEmployees()
Dim tbl As DataTable = EmpDataSet.Tables(0)
Dim Row As DataRow
Dim MyString As String
For Each Row In tbl.Rows
Debug.WriteLine(Row(0)) '' This line builds fine
MyString = Row(0) '' This line does not build
Next
End Sub
The IDE won't build this code, and mousing over the little squigglies
gives me "Option Strict On disallows implicit conversions from
'System.Object' to 'String'".
If I comment out the "MyString" line, the code builds and runs as you
would expect. This code follows just about every example I've seen of
looping through the rows in a datatable.
Now, I know that I can change the "MyString" line to this...
MyString = CStr(Row(0))
....and it will build and run fine, but I'm not sure why I should have
to do that, or why none of the examples that I'm seeing require such
an explicit conversion.
Thanks in advance.
Duane