How can I view DataSet content in Command Window?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

?ds.Tables[0].Rows[0][0,DataRowVersion.Current]

....gives me the error message ...
error: object 'ds.Tables[0].Rows[0]' doesn't have an indexer
 
I could not get this to work for me? The systax seems to be missing the row
# index.

Thanks!

W.G. Ryan eMVP said:
You can use the ColumnReference then the DataRowVersion ie

ds.Tables[0].Rows["Whatever", DataRowVersion.Current];
http://authors.aspalliance.com/aspxtreme/sys/Data/datarowclassitem4.aspx

I know this does you no good now but the new version of VS.NET has some
features for viewing variables that's so cool it defies words. When you
type it in it has drop downs and everything.

Cheers,

Bill
Dave Boal said:
?ds.Tables[0].Rows[0][0,DataRowVersion.Current]

...gives me the error message ...
error: object 'ds.Tables[0].Rows[0]' doesn't have an indexer
 
Dave, I'm sorry there was a typo, an index was needed again after the .Rows.

I just wrote some code using the same variable names that you have and
actually using the same declaration and It's not having an issue. If I
change it from Current for instance to a value that's not available then
I'll get an exception - same goes if I don't have a row there that I'm
trying to reference but that's absolutely as expected. Not sure what else it
is...

Dave Boal said:
I could not get this to work for me? The systax seems to be missing the row
# index.

Thanks!

W.G. Ryan eMVP said:
You can use the ColumnReference then the DataRowVersion ie

ds.Tables[0].Rows["Whatever", DataRowVersion.Current];
http://authors.aspalliance.com/aspxtreme/sys/Data/datarowclassitem4.aspx

I know this does you no good now but the new version of VS.NET has some
features for viewing variables that's so cool it defies words. When you
type it in it has drop downs and everything.

Cheers,

Bill
Dave Boal said:
?ds.Tables[0].Rows[0][0,DataRowVersion.Current]

...gives me the error message ...
error: object 'ds.Tables[0].Rows[0]' doesn't have an indexer
 
Seeing as how OE kills ASCX files, this is the code:

<%@Control Language="VB"%>
<%@Import Namespace="System.Data" %>

<b><div id="divCaption" runat="server" /></b>
<div id="divValues" runat="server" /><p />

<script language="VB" runat="server">

Public Sub ShowValues(objTable As DataTable, strCaption As String)

Dim intRow, intCol As Integer
Dim objRow As DataRow
Dim strColName, strResult As String

'iterate through all the rows in the Table
For intRow = 0 To objTable.Rows.Count - 1

'get a reference to this row
objRow = objTable.Rows(intRow)

'show row state and row number
strResult &= "<b>" & objRow.RowState.ToString() & "</b> row [" _
& intRow & "] &nbsp; <b>Current</b>: "

'iterate through all the columns in this row
For intCol = 0 To objTable.Columns.Count - 1

Try

'get the name of this column and the Current value
strColName = objTable.Columns(intCol).ColumnName
strResult &= strColName & "=" _
& objRow(strColName, DataRowVersion.Current) & " "

Catch

strResult &= "{n/a}, " 'no Current value available

End Try

Next

strResult &= " &nbsp; <b>Original</b>: "

'iterate through the columns in the same row again
For intCol = 0 To objTable.Columns.Count - 1

Try

'get the name of this column and the Current value
strColName = objTable.Columns(intCol).ColumnName
strResult &= strColName & "=" _
& objRow(strColName, DataRowVersion.Original) & " "

Catch

strResult &= "{n/a}, " 'no Original value available

End Try

Next

strResult &= "<br />"

'get any RowError value and display this
If objRow.RowError.Length > 0 Then
strResult &= " &nbsp; <b>* Row Error</b>: " & objRow.RowError & "<br
/>"
End If

Next

'put text into <div> controls on page
divValues.InnerHtml = strResult
divCaption.InnerHtml = strCaption & ":"

End Sub

</script>
 
It can be some limitation on the maximum characters output for the command
window, try using .WriteXML and write it to disk to look it IE.

(If you can, of course, do not destroy your security settings to do that...)


Regards,
Victor Reboucas




Hi,

U can view the entire contents of the DataSet by using the GetXml method
on
a DataSet object in Command Window.

Take look at it here:
http://msdn.microsoft.com/library/d...ml/frlrfsystemdatadatasetclassgetxmltopic.asp

Regards,
Vikram, S


Dave Boal said:
?ds.Tables[0].Rows[0][0,DataRowVersion.Current]

...gives me the error message ...
error: object 'ds.Tables[0].Rows[0]' doesn't have an indexer
 
Back
Top