K
Keith
Hello everyone. With the enormously helpful developers
out there I was able to customize the code below (most of
which was supplied TO me (Thank you)). However, what I'm
finding is that there is a speed delay problem - from when
the button is clicked and the results are displayed.
While I could create a 'progress bar' control - to fill
the time - while the delay is happening - I would like to
find out the source of the delay. Given it is only 5-6
seconds - but as I place more data in the database - I
believe that delay will increase. I did run the SELECT
statement from directly on the Query Analyzer on the PPC
using the same small database (yyg) - and it took no time
at all (Results: 14 row(s) affect - Elapsed time
00:00:00). My conclusion is this delay is coming about
from the Datareader - the While loop - yet I'm not sure.
And that is really the question: Based on the code below -
where do you think the delay is coming from?
Btw, it seems that once the code under this button is run
the 1st time - all subsequent times are much faster.
Here's the code. Thank you all:
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As System.Data.SqlServerCe.SqlCeConnection
Dim cmd As System.Data.SqlServerCe.SqlCeCommand
Dim dtr As System.Data.SqlServerCe.SqlCeDataReader
Try
' Open the database.
Dim s As String
cn = New
System.Data.SqlServerCe.SqlCeConnection("DataSource=My
Documents\yyg.sdf")
cn.Open()
' Retrieve a list of the contacts.
cmd = New System.Data.SqlServerCe.SqlCeCommand
("SELECT First, Last FROM Two", cn)
dtr = cmd.ExecuteReader()
' Load the list into the contacts combobox.
ListBox1.Items.Clear()
TextBox2.Text = Mid(s, 1, Len(TextBox1.Text))
While dtr.Read()
s = dtr("First") '& " " & dtr("Last")
'or dtr(0) & " " & dtr(1)
If Mid(s, 1, Len(TextBox1.Text)) =
TextBox1.Text Then
ListBox1.Items.Add(s)
Else
Dim norecord As String = "Not Records
Exit"
ListBox1.Items.Add(norecord)
End If
End While
' Clean-up.
Catch sqlex As SqlCeException
Dim sqlerror As SqlCeError
For Each sqlerror In sqlex.Errors
MessageBox.Show(sqlerror.Message)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
dtr.Close()
cn.Close()
End Try
End Sub
out there I was able to customize the code below (most of
which was supplied TO me (Thank you)). However, what I'm
finding is that there is a speed delay problem - from when
the button is clicked and the results are displayed.
While I could create a 'progress bar' control - to fill
the time - while the delay is happening - I would like to
find out the source of the delay. Given it is only 5-6
seconds - but as I place more data in the database - I
believe that delay will increase. I did run the SELECT
statement from directly on the Query Analyzer on the PPC
using the same small database (yyg) - and it took no time
at all (Results: 14 row(s) affect - Elapsed time
00:00:00). My conclusion is this delay is coming about
from the Datareader - the While loop - yet I'm not sure.
And that is really the question: Based on the code below -
where do you think the delay is coming from?
Btw, it seems that once the code under this button is run
the 1st time - all subsequent times are much faster.
Here's the code. Thank you all:
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim cn As System.Data.SqlServerCe.SqlCeConnection
Dim cmd As System.Data.SqlServerCe.SqlCeCommand
Dim dtr As System.Data.SqlServerCe.SqlCeDataReader
Try
' Open the database.
Dim s As String
cn = New
System.Data.SqlServerCe.SqlCeConnection("DataSource=My
Documents\yyg.sdf")
cn.Open()
' Retrieve a list of the contacts.
cmd = New System.Data.SqlServerCe.SqlCeCommand
("SELECT First, Last FROM Two", cn)
dtr = cmd.ExecuteReader()
' Load the list into the contacts combobox.
ListBox1.Items.Clear()
TextBox2.Text = Mid(s, 1, Len(TextBox1.Text))
While dtr.Read()
s = dtr("First") '& " " & dtr("Last")
'or dtr(0) & " " & dtr(1)
If Mid(s, 1, Len(TextBox1.Text)) =
TextBox1.Text Then
ListBox1.Items.Add(s)
Else
Dim norecord As String = "Not Records
Exit"
ListBox1.Items.Add(norecord)
End If
End While
' Clean-up.
Catch sqlex As SqlCeException
Dim sqlerror As SqlCeError
For Each sqlerror In sqlex.Errors
MessageBox.Show(sqlerror.Message)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
dtr.Close()
cn.Close()
End Try
End Sub