M
Mike
I recently upgraded from VB6 to VB.net and decided that i
would like to update a program i use a lot. The Program
Connects to a M$ access database (access 2000). It reads
in server logs and parses the infomation using the Split
command and a select statement to pick out appropriate
words. It then inserts each 'record' (each line in the
server log contains 1 record) into the database.
Under VB6 i used DAO (of course) and my program was fine.
The searching was Fast, the data retreival was fast, the
input FAST. It took less than 2 seconds to parse a single
log file and insert the whole thing into the database. I
timed it. To parse 62,398 records it took 6 minutes 23
seconds, Give or take 10 seconds.
Now i switched to ADO.net (thinking new = better ops
I use Datasets to populate a Datagrid (easy and fast). I
use dataadapters to insert the info to the database by
updating the datset and using the .update command.
Now i guess my question is why does it take my program 38
minutes 54 seconds (give or take 1 minute) to parse
62,398 records? ??!?!!?!?!?!?
When i insert the data i dont fill any datasets
(something which could if in a loop add vital seconds to
each loop) i dont do anything other than add the data
then update.
Now i cant for the Life of me imagine that the M$
programmers Butchered the SPlit Code. So in my opinion i
rule that out. So im afriad the only thing left is the
data access....
Sample Code::
-----------------
PlayerDA.InsertCommand = New OleDbCommand("INSERT
INTO Players ([Date], [Time], Name, WonID, IPAddress)
Values(?,?,?,?,?)", DBConnection)
PlayerDA.InsertCommand.CommandType =
CommandType.Text
PlayerDA.InsertCommand.Parameters.Add("@Date",
OleDbType.Char, 50, "Date")
PlayerDA.InsertCommand.Parameters.Add("@Time",
OleDbType.Char, 50, "Time")
PlayerDA.InsertCommand.Parameters.Add("@Name",
OleDbType.Char, 50, "Name")
PlayerDA.InsertCommand.Parameters.Add("@WonID",
OleDbType.Char, 50, "WonID")
PlayerDA.InsertCommand.Parameters.Add
("@IPAddress", OleDbType.Char, 50, "IPAddress")
DBConnection.Open()
Dim newRow As DataRow = DataSet1.Tables
("Players").NewRow()
newRow("Date") = ""
newRow("Time") = ""
newRow("Name") = ""
newRow("WonID") = ""
newRow("IPAddress") = ""
DataSet1.Tables("players").Rows.Add(newRow)
PlayerDA.Update(DataSet1, "Players")
DBConnection.Close()
----------------
Insert blank... is it that ^^^ ? or is it my Split code?
Sample Code:
------------------------------
Do Until LineCount = NumberOfLinesInLogFile
UnformattedLogLine = LogFile(LineCount).Word
UnformattedLogLineSplit = Split
(UnformattedLogLine, " ")
UnFormattedLogLineNumOfValues = UBound
(UnformattedLogLineSplit)
'Formatting the Info
Do Until GettingParsedValues >
UnFormattedLogLineNumOfValues
Select Case GettingParsedValues
Case 0
Case 1
Case 2
Temp = UnformattedLogLineSplit
(GettingParsedValues)
ParsedArray(0) = Temp.Trim
(TrimValues.ToCharArray())
Case 3
Temp = UnformattedLogLineSplit
(GettingParsedValues)
ParsedArray(1) = Temp.Trim
(TrimValues.ToCharArray())
Case 4
GettingName = Split
(UnformattedLogLine, "NAME:")
GettingNameUpper = UBound
(GettingName)
If GettingNameUpper > 1 Then
GettingNameFoundToSplit =
GettingName(1)
GettingName2 = Split
(GettingNameFoundToSplit, ",")
Name = Trim(GettingName2(0))
ParsedArray(2) = Name
Else
GettingName = Split
(UnformattedLogLine, " ")
Name = Trim(GettingName(4))
ParsedArray(2) = Name
End If
Case 5
Case 6
Case 7
GettingWonID = Split
(UnformattedLogLine, ":")
gettingwonidupper = UBound
(GettingWonID)
If gettingwonidupper > 3 Then
GettingWonIDFoundtoSplit =
GettingWonID(5)
GettingWonID2 = Split
(GettingWonIDFoundtoSplit, ",")
WonID = Trim(GettingWonID2(0))
ParsedArray(3) = WonID
Else
GettingWonID = Split
(UnformattedLogLine, ",")
WonID = Trim(GettingWonID(2))
ParsedArray(3) = WonID
End If
Case 8
GettingIP = Split
(UnformattedLogLine, "IP:")
GettingIPFoundToSplit = GettingIP
(1)
GettingIP2 = Split
(GettingIPFoundToSplit, ":")
IPAddress = Trim(GettingIP2(0))
ParsedArray(4) = IPAddress
Case Else
End Select
GettingParsedValues = GettingParsedValues
+ 1
Loop
IncrementLineCount()
IncrementRow()
GettingParsedValues = 0
InsertingParsedValues = 0
Col = 0
Insert_to_database()
Loop
--------------------
I really would like some insight from anyone I will be
absolutely speachless to think my split code is causing
this kind of performance degredation especially when its
IDENTICAL to the previous version (under vb6).
So im pretty sure its my Database code. This is my first
ADO.net so be kind
would like to update a program i use a lot. The Program
Connects to a M$ access database (access 2000). It reads
in server logs and parses the infomation using the Split
command and a select statement to pick out appropriate
words. It then inserts each 'record' (each line in the
server log contains 1 record) into the database.
Under VB6 i used DAO (of course) and my program was fine.
The searching was Fast, the data retreival was fast, the
input FAST. It took less than 2 seconds to parse a single
log file and insert the whole thing into the database. I
timed it. To parse 62,398 records it took 6 minutes 23
seconds, Give or take 10 seconds.
Now i switched to ADO.net (thinking new = better ops
I use Datasets to populate a Datagrid (easy and fast). I
use dataadapters to insert the info to the database by
updating the datset and using the .update command.
Now i guess my question is why does it take my program 38
minutes 54 seconds (give or take 1 minute) to parse
62,398 records? ??!?!!?!?!?!?
When i insert the data i dont fill any datasets
(something which could if in a loop add vital seconds to
each loop) i dont do anything other than add the data
then update.
Now i cant for the Life of me imagine that the M$
programmers Butchered the SPlit Code. So in my opinion i
rule that out. So im afriad the only thing left is the
data access....
Sample Code::
-----------------
PlayerDA.InsertCommand = New OleDbCommand("INSERT
INTO Players ([Date], [Time], Name, WonID, IPAddress)
Values(?,?,?,?,?)", DBConnection)
PlayerDA.InsertCommand.CommandType =
CommandType.Text
PlayerDA.InsertCommand.Parameters.Add("@Date",
OleDbType.Char, 50, "Date")
PlayerDA.InsertCommand.Parameters.Add("@Time",
OleDbType.Char, 50, "Time")
PlayerDA.InsertCommand.Parameters.Add("@Name",
OleDbType.Char, 50, "Name")
PlayerDA.InsertCommand.Parameters.Add("@WonID",
OleDbType.Char, 50, "WonID")
PlayerDA.InsertCommand.Parameters.Add
("@IPAddress", OleDbType.Char, 50, "IPAddress")
DBConnection.Open()
Dim newRow As DataRow = DataSet1.Tables
("Players").NewRow()
newRow("Date") = ""
newRow("Time") = ""
newRow("Name") = ""
newRow("WonID") = ""
newRow("IPAddress") = ""
DataSet1.Tables("players").Rows.Add(newRow)
PlayerDA.Update(DataSet1, "Players")
DBConnection.Close()
----------------
Insert blank... is it that ^^^ ? or is it my Split code?
Sample Code:
------------------------------
Do Until LineCount = NumberOfLinesInLogFile
UnformattedLogLine = LogFile(LineCount).Word
UnformattedLogLineSplit = Split
(UnformattedLogLine, " ")
UnFormattedLogLineNumOfValues = UBound
(UnformattedLogLineSplit)
'Formatting the Info
Do Until GettingParsedValues >
UnFormattedLogLineNumOfValues
Select Case GettingParsedValues
Case 0
Case 1
Case 2
Temp = UnformattedLogLineSplit
(GettingParsedValues)
ParsedArray(0) = Temp.Trim
(TrimValues.ToCharArray())
Case 3
Temp = UnformattedLogLineSplit
(GettingParsedValues)
ParsedArray(1) = Temp.Trim
(TrimValues.ToCharArray())
Case 4
GettingName = Split
(UnformattedLogLine, "NAME:")
GettingNameUpper = UBound
(GettingName)
If GettingNameUpper > 1 Then
GettingNameFoundToSplit =
GettingName(1)
GettingName2 = Split
(GettingNameFoundToSplit, ",")
Name = Trim(GettingName2(0))
ParsedArray(2) = Name
Else
GettingName = Split
(UnformattedLogLine, " ")
Name = Trim(GettingName(4))
ParsedArray(2) = Name
End If
Case 5
Case 6
Case 7
GettingWonID = Split
(UnformattedLogLine, ":")
gettingwonidupper = UBound
(GettingWonID)
If gettingwonidupper > 3 Then
GettingWonIDFoundtoSplit =
GettingWonID(5)
GettingWonID2 = Split
(GettingWonIDFoundtoSplit, ",")
WonID = Trim(GettingWonID2(0))
ParsedArray(3) = WonID
Else
GettingWonID = Split
(UnformattedLogLine, ",")
WonID = Trim(GettingWonID(2))
ParsedArray(3) = WonID
End If
Case 8
GettingIP = Split
(UnformattedLogLine, "IP:")
GettingIPFoundToSplit = GettingIP
(1)
GettingIP2 = Split
(GettingIPFoundToSplit, ":")
IPAddress = Trim(GettingIP2(0))
ParsedArray(4) = IPAddress
Case Else
End Select
GettingParsedValues = GettingParsedValues
+ 1
Loop
IncrementLineCount()
IncrementRow()
GettingParsedValues = 0
InsertingParsedValues = 0
Col = 0
Insert_to_database()
Loop
--------------------
I really would like some insight from anyone I will be
absolutely speachless to think my split code is causing
this kind of performance degredation especially when its
IDENTICAL to the previous version (under vb6).
So im pretty sure its my Database code. This is my first
ADO.net so be kind