hi everyone,
i would like to ask how am i be able to populate those controls faster... i already put an index to the table.. and yet... my program hangs up for a little while.. it takes about 10 seconds or so... and sometimes... it takes too much of my cpu usage... i use OleDbDataReader to get the data...
here is an example of my code...
i populate the textbox and the treeview at the same time when i click the button... any ideas
i would like to ask how am i be able to populate those controls faster... i already put an index to the table.. and yet... my program hangs up for a little while.. it takes about 10 seconds or so... and sometimes... it takes too much of my cpu usage... i use OleDbDataReader to get the data...
here is an example of my code...
VB.NET:
Dim cmdBookInfo As String = "SELECT BV.BookNum, BV.Chapter, BV.Verse, BV.Narration, " & _
"BB.BookName FROM BibleVerses BV, BibleBooks BB " & _
"Where BV.BookNum = " & BookNumTag & _
" AND BV.BookNum = BB.BookNum ORDER By Chapter, Verse"
cnnBL.Open()
Dim WCReader As OleDb.OleDbDataReader
Dim WCCommand As New OleDb.OleDbCommand(cmdBookInfo, cnnBL)
WCReader = WCCommand.ExecuteReader()
If WCReader.HasRows Then
Do While WCReader.Read()
Dim chapter, verse, narration, nr As String
chapter = WCReader("Chapter")
verse = WCReader("Verse")
narration = WCReader("Narration")
nr = "CHAPTER"
If chapter = 0 Then
If verse = 0 Then
LabelNarration.Text &= ""
End If
Else
If verse = 0 And narration.ToLower.Contains(nr.ToLower) Then
LabelNarration.Text &= ""
ElseIf verse = 1 Then
LabelNarration.Text &= nr & " " & chapter & vbCrLf & vbCrLf
LabelNarration.Text &= verse & " "
LabelNarration.Text &= narration & vbCrLf & vbCrLf
Else
LabelNarration.Text &= verse & " "
LabelNarration.Text &= narration & vbCrLf & vbCrLf
End If
End If
Loop
Else
LabelNarration.Text = "There are no data."
End If
Dim cmdBibleInfo As String = "SELECT BV.BookNum, BV.Chapter, BV.Verse, BV.Narration, " & _
"BB.BookName FROM BibleVerses BV, BibleBooks BB " & _
"Where BV.BookNum = " & BookNumTag & _
" AND BV.BookNum = BB.BookNum ORDER By Chapter, Verse"
Dim InfoReader As OleDb.OleDbDataReader
Dim InfoCommand As New OleDb.OleDbCommand(cmdBibleInfo, cnnBL)
InfoReader = InfoCommand.ExecuteReader()
If InfoReader.HasRows Then
While InfoReader.Read()
LabelBookName.Text = InfoReader.GetValue(InfoReader.GetOrdinal("BookName")).ToString() ' BookNum
Dim Chapter, Verse As Integer
Chapter = InfoReader.GetValue(InfoReader.GetOrdinal("Chapter")).ToString() ' Chapter
Verse = InfoReader.GetValue(InfoReader.GetOrdinal("Verse")).ToString() ' Verse
LabelChapterVerse.Text = " "
BookNumName = "Book " & BookNumTag & " : " & LabelBookName.Text
End While
Else
'MsgBox("No Data")
End If
InfoCommand.Dispose()
WCCommand.Dispose()
cnnBL.Close()
i populate the textbox and the treeview at the same time when i click the button... any ideas