Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a better performance strategy?
Message
From
03/08/2007 13:19:27
Terry Tuell
Stephens Production Company
Fort Smith, Arkansas, United States
 
 
To
03/08/2007 11:25:29
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01245803
Message ID:
01245855
Views:
23
There's not much code to it, but here it is.

The following code is in the Class called myTargetTblBLL. The code you are seeing has been condensed to save space and hopefully make it more readable.

' This is the Update function. If the record already exists, just update the values

Public Function UpdateCurrentRec( _
ByVal WellZoneID, _
ByVal NameID, _
ByVal GWI, _
ByVal NRI, _
ByVal InterestType, _
ByVal DateEffectiveEX, _
ByVal PayCode, _
ByVal ProdType, _
ByVal ProdDesc) _
As Integer

Dim myTargetTbls As MyDataSet.myTargetTblDataTable = Adapter.GetImportKey(NameID, WellZoneID, InterestType, DateEffectiveEX, PayCode, ProdType)

If myTargetTbls.Count = 0 Then
Return 0
Else
Dim DOIRecord As MyDataSet.myTargetTblRow = myTargetTbls(0)
DOIRecord.GWI = GWI
DOIRecord.NRI = NRI
DOIRecord.ProdDesc = ProdDesc

Dim testdate As Date
testdate = DateAdd(DateInterval.Day, DateEffectiveEX, Day1)

DOIRecord.DateEffective = testdate
DOIRecord.IsActive = True

Dim RowsAffected As Integer = Adapter.Update(myTargetTbls)

Return RowsAffected
End If
End Function


' This is the Add Function for new records


Public Function AddNewRecord( _
ByVal WellZoneID, _
ByVal NameID, _
ByVal GWI, _
ByVal NRI, _
ByVal InterestType, _
ByVal DateEffectiveEX, _
ByVal PayCode, _
ByVal ProdType, _
ByVal ProdDesc) _
As Boolean

Dim myTargetTbls As New MyDataSet.myTargetTblDataTable()
Dim DOIRecord As MyDataSet.myTargetTblRow = myTargetTbls.NewmyTargetTblRow()

DOIRecord.WellZoneID = WellZoneID
DOIRecord.NameID = NameID
DOIRecord.GWI = GWI
DOIRecord.NRI = NRI
DOIRecord.InterestType = InterestType
DOIRecord.DateEffective_EX = DateEffectiveEX
DOIRecord.PayCode = PayCode
DOIRecord.ProdType = ProdType
DOIRecord.ProdDesc = ProdDesc
DOIRecord.DateEffective = DateAdd(DateInterval.Day, DateEffectiveEX, Day1)
DOIRecord.IsActive = True

myTargetTbls.AddmyTargetTblRow(DOIRecord)
Dim RowsAffected As Integer = Adapter.Update(myTargetTbls)

Return RowsAffected = 1

End Function



' The following code is in the Presentation layer. This section is
' called after the original ASCII file has been prepared for import
' This is also the section where it is going into it's 6th hour of
' processing.

Public Sub ToSQLWINRI()
Dim myTargetTblAPI As New myTargetTblBLL

Dim TXT As String
Dim line As String
Dim aData() As String
Dim sWellID As String
Dim nNameID As Integer
Dim nGWI As Decimal
Dim nNRI As Decimal
Dim sInterestType As String
Dim iExcaliburED As Integer
Dim sPayCode As String
Dim sProdType As String
Dim sProdDesc As String

TXT = "C:\Temp\" & WINRITXT

Dim sr As New StreamReader(New FileStream(TXT, FileMode.Open, FileAccess.Read), System.Text.Encoding.Default, False)


'
' Set all records as 'False' at the beginning. As records are examined,
' flag them as true. When complete, delete all Records still flagged
' as 'False' Setting all records to 'False' does not take any time
' either.

myTargetTblAPI.SetISActive(False)

' process ASCII file. Now the long wait sets in.

Do
line = sr.ReadLine()
If line Is Nothing Then
Exit Do
End If

iCurRecord += 1

aData = line.Split("|")

Try

If aData.GetUpperBound(0) = 8 Then
sWellID = aData(0)
nNameID = Val(aData(1))
nGWI = Val(aData(2)) / 100000000
nNRI = Val(aData(3)) / 100000000
sInterestType = aData(4)
iExcaliburED = Val(aData(5))
sPayCode = aData(6)
sProdType = aData(7)
sProdDesc = aData(8)


UpdateStatus = myTargetTblAPI.UpdateCurrentRec( _
sWellID, _
nNameID, _
nGWI, _
nNRI, _
sInterestType, _
iExcaliburED, _
sPayCode, _
sProdType, _
sProdDesc)

If UpdateStatus = 0 Then
AddStatus = myTargetTblAPI.AddNewRecord( _
sWellID, _
nNameID, _
nGWI, _
nNRI, _
sInterestType, _
iExcaliburED, _
sPayCode, _
sProdType, _
sProdDesc)


Catch ex As Exception
'
' Use various statements to display exception reason
End Try

Loop Until line Is Nothing


sr.Close()

' Delete all records still flagged as 'False'

myTargetTblAPI.DeleteInActive()

End Sub
Previous
Reply
Map
View

Click here to load this message in the networking platform