There is a report on our intranet that has two columns of numbers we use for cost tracking. There are 8000+ line items, I need to get two columns, the first and last.
The code works Ok for a while but then locks up. I suspect a buffer is full or something.
What it does is load the whole report into a string then goes line by line and extracts the two numbers then runs an SP to insert them in a table, this is done is a while loop. but after a while, pun inteneded, it just hangs. I then look in the SQL table and it get to about 300-400 records. is there a better way to rrad that much data in insert it in a SQL table?
Or Any other Ideas. we can't get the data any other way but this report. It was copied and pasted into Excel b4 but I want to automate it as part of the Time keeping App I'm creating. We need to do this weekly.
The code works Ok for a while but then locks up. I suspect a buffer is full or something.
What it does is load the whole report into a string then goes line by line and extracts the two numbers then runs an SP to insert them in a table, this is done is a while loop. but after a while, pun inteneded, it just hangs. I then look in the SQL table and it get to about 300-400 records. is there a better way to rrad that much data in insert it in a SQL table?
Or Any other Ideas. we can't get the data any other way but this report. It was copied and pasted into Excel b4 but I want to automate it as part of the Time keeping App I'm creating. We need to do this weekly.
Code:
Dim strResult As String
Dim objResponse As WebResponse
Dim objRequest As WebRequest = HttpWebRequest.Create(strURL)
Dim SPMID As String = ""
Dim CostTracker = ""
Dim StartingData As Boolean = False
objResponse = objRequest.GetResponse()
Using sr As New StreamReader(objResponse.GetResponseStream())
strResult = sr.ReadToEnd()
sr.Close()
End Using
Dim aLine As String = ""
Dim aParagraph As String = ""
Dim strReader As New StringReader(strResult)
While True
aLine = strReader.ReadLine()
If aLine Is Nothing Then
aParagraph = aParagraph & vbCrLf
Exit While
ElseIf InStr(1, aLine, "----") Then 'look for line accross page to start with actual data
StartingData = True
ElseIf StartingData Then
'Debug.Print(aLine)
CostTracker = Trim(Mid(aLine, 1, 13))
SPMID = Trim(Mid(aLine, 160, 18))
Debug.Print(SPMID, CostTracker)
Dim Retval As String = sp_SOWInsertSPMID(SPMID, CostTracker)
Else
End If
End While
[/code
DougP