Z
Zahid
Hi,
My application retrieves a max of 20 rows of data (40
columns per row) each time a SQL Query is executed and as
a result refreshed the text and color on buttons in the
application. For some strange reason it takes 2-3 secs to
execute the query and return the data (20 rows).
What is actually happening is that I am executing 3 small
queries to obtain 3 seperate values and I believe this is
where the delay is happening. Here is the code:
If gListMenu = 0 Then
'Dont bother searching
Else
'Search for listMenuLink
gMyCommand.CommandText = "Select link from
listHdrs where listNo = " & gListMenu
gRdr = gMyCommand.ExecuteReader
(CommandBehavior.SingleRow)
If gRdr.Read() Then
gListMenuLink = gRdr.GetInt32(0)
gRdr.Close()
Else
gRdr.Close()
End If
End If
If gListQual = 0 Then
'Dont bother searching
Else
'Search for listMenuLink
gMyCommand.CommandText = "Select link from
listHdrs where listNo = " & gListQual
gRdr = gMyCommand.ExecuteReader
(CommandBehavior.SingleRow)
If gRdr.Read() Then
gListQualLink = gRdr.GetInt32(0)
gRdr.Close()
Else
gRdr.Close()
End If
End If
If gListExtra = 0 Then
'Dont bother searching
Else
'Search for listExtraLink
gMyCommand.CommandText = "Select link from
listHdrs where listNo = " & gListExtra
gRdr = gMyCommand.ExecuteReader
(CommandBehavior.SingleRow)
If gRdr.Read() Then
gListExtraLink = gRdr.GetInt32(0)
gRdr.Close()
Else
gRdr.Close()
End If
End If
This is an unacceptable speed - im sure it can be much
faster - like 1 second execution time?
Any ideas on how to improve the speed? I would use batch
queries but its not supported on SQLServerCE.
Thanks in advance.
My application retrieves a max of 20 rows of data (40
columns per row) each time a SQL Query is executed and as
a result refreshed the text and color on buttons in the
application. For some strange reason it takes 2-3 secs to
execute the query and return the data (20 rows).
What is actually happening is that I am executing 3 small
queries to obtain 3 seperate values and I believe this is
where the delay is happening. Here is the code:
If gListMenu = 0 Then
'Dont bother searching
Else
'Search for listMenuLink
gMyCommand.CommandText = "Select link from
listHdrs where listNo = " & gListMenu
gRdr = gMyCommand.ExecuteReader
(CommandBehavior.SingleRow)
If gRdr.Read() Then
gListMenuLink = gRdr.GetInt32(0)
gRdr.Close()
Else
gRdr.Close()
End If
End If
If gListQual = 0 Then
'Dont bother searching
Else
'Search for listMenuLink
gMyCommand.CommandText = "Select link from
listHdrs where listNo = " & gListQual
gRdr = gMyCommand.ExecuteReader
(CommandBehavior.SingleRow)
If gRdr.Read() Then
gListQualLink = gRdr.GetInt32(0)
gRdr.Close()
Else
gRdr.Close()
End If
End If
If gListExtra = 0 Then
'Dont bother searching
Else
'Search for listExtraLink
gMyCommand.CommandText = "Select link from
listHdrs where listNo = " & gListExtra
gRdr = gMyCommand.ExecuteReader
(CommandBehavior.SingleRow)
If gRdr.Read() Then
gListExtraLink = gRdr.GetInt32(0)
gRdr.Close()
Else
gRdr.Close()
End If
End If
This is an unacceptable speed - im sure it can be much
faster - like 1 second execution time?
Any ideas on how to improve the speed? I would use batch
queries but its not supported on SQLServerCE.
Thanks in advance.