what is the vb.net equivalent or similar of recordset.underlyingvalue and recordset.value in vb?
I’m converting a vb application to vb.net and i’ve replaced the recordsets with datasets but i have not been able to figure this out. any help would be really appreciated.
i’ve tried making a copy of the dataset and comparing values to track the changes but that doesn’t seem very efficient. Here is a piece of code that i’m trying to convert.
For Each fld In rs.Fields
bfldChanged = False
Select Case fld.Type
Case adDate, adDBDate, adDBTime, adDBTimeStamp:
If IsDate(fld.UnderlyingValue) And Not IsDate(fld.Value) Then
bfldChanged = True
ElseIf Not IsDate(fld.UnderlyingValue) And IsDate(fld.Value) Then
bfldChanged = True
ElseIf IsDate(fld.UnderlyingValue) And IsDate(fld.Value) Then
If fld.UnderlyingValue <> fld.Value Then
bfldChanged = True
Else
bfldChanged = False
End If
Else
bfldChanged = False
End If
Case Else:
If (fld.UnderlyingValue <> fld.Value) Then
bfldChanged = True
Else
bfldChanged = False
End If
End Select
Next
There is no equivalent to that particular property. Data Access in .NET is very different than Data Access in VB6 and prior. The DataTable is only marginally like a RecordSet.
However, looking at the code, it looks like you’re just checking to see if the table contains changes. You can use the DataTable.GetChanges() method to determine this a lot more simply.
Not part of the official answer, but a general recommendation.
I’ve converted tons of VB6 apps to .NET apps, and experience has taught me that doing a line-by-line conversion attempt is almost always a bad idea. The two are quite different, and in every case, it’s proved to be more efficient and eror-free to just start over from scratch. Make sure I understand what the VB6 app did (requirementes) map it all out, flowchart everything, and then build the .NET version from scratch. I’ve had nothing but headaches doing it any other way.