Datasets (DS) and DataTables (DT) in .NET

Question was asked:

When I’m using a recordset in VB6, I can use either of the following:

rstRS.Fields(“FieldName”).Value

rstRS!FieldName

Do both of those work in .NET?

 

Answer:

You don’t read the Dataset value directly

You put the dataset into a datatable and then you can reference it.

Like the following: PlanIdSearchComboBoxDT.Rows(i).Item("PlanID")

Example:

ReportMobiusDS = NADPMobiusReportDA.GetReportMobiusDataSet(currentError, _NADPMobiusReportDetail, StoredProcedureName)

ReportMobiusDS = NADPMobiusReportDA.GetReportMobiusDataSet(currentError, _NADPMobiusReportDetail, StoredProcedureName)

If Not currentError.Severity = FBError.ErrorSeverity.NoErrors Then MessageBox.Show(currentError.FriendlyError)

Return

Else

‘We then insert the report dataset in a data table in order to preserve formatting

dt = ReportMobiusDS.Tables(0)

‘NOTE: Tables are returned select statements.  The first return is indexed 0.  If you have multiple selects returning from a stored procedure you can call it by the zero based index of the table. 

Dim row As DataRow

For Each row In dt.Rows

If row("strLineToPrint").ToString <> "" Then s.WriteLine(CStr(row("strLineToPrint")).ToUpper)

Next

…continue code…

Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: