Controls mapped to Database

Z

Zahid

Hi,

I have a SQLServerCE database linked to my PocketPC
application. What i am doing is reading a row of data
from a table and assigning the values from that row to a
custom control (picture button). The rows in the database
table contain the configuration setting of the custom
designed picture button such as background color,
foreground colour, text etc.

I have about 16 of these custom controls on my form and
the user will regularly need to refresh these so as to
read new picture button settings from the database. The
problem im having is that the refresh speed is a little
slow (4 secs)- causing a delay for the user. I would like
to reduce it to at most 2 secs.

Is there a faster alternative that is not memory
intensive? There will be times probably where I will need
to read 70/80 rows from the database.

Here is my code:

Dim Counter As Integer = 0
Dim bColorFromDB, fColorFromDB As String
gMyCommand.CommandText = "Select ItemText,
ForeGround,Background, ListNo from ListItems"

gRdr = gMyCommand.ExecuteReader
Dim NewStr As String

While (Counter < 16 And gRdr.Read())
bDo_PaintBackGround = False
m = Frm2.Panel1.Controls(Counter)

'Read the Button color setting from the
'database field backgroundColor

m.Text = gRdr.GetString(0)
fColorFromDB = gRdr.GetInt32(1)
bColorFromDB = gRdr.GetInt32(2)

If fColorFromDB = 1 Then
m.ForeColor = Color.FromArgb(0, 0, 0)
ElseIf fColorFromDB = 2 Then
m.ForeColor = Color.FromArgb(0, 0, 168)
ElseIf fColorFromDB = 3 Then
m.ForeColor = Color.FromArgb(0, 168, 0)
Else

End If


If bColorFromDB = 1 Then
m.buttonImg = m.MakeBitmap(0, 0, 0,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 0
m.RgbB = 0
ElseIf bColorFromDB = 2 Then
m.buttonImg = m.MakeBitmap(0, 0, 168,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 0
m.RgbB = 168
ElseIf bColorFromDB = 3 Then
m.buttonImg = m.MakeBitmap(0, 168, 0,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 168
m.RgbB = 0
Else

End If

bDo_PaintBackGround = True
Frm2.Panel1.Controls(Counter).Refresh()
Counter += 1
End While



Thanks in advance.
 
Z

Zahid

Hi,

Any ideas anyone? Hope so.

-----Original Message-----
Hi,

I have a SQLServerCE database linked to my PocketPC
application. What i am doing is reading a row of data
from a table and assigning the values from that row to a
custom control (picture button). The rows in the database
table contain the configuration setting of the custom
designed picture button such as background color,
foreground colour, text etc.

I have about 16 of these custom controls on my form and
the user will regularly need to refresh these so as to
read new picture button settings from the database. The
problem im having is that the refresh speed is a little
slow (4 secs)- causing a delay for the user. I would like
to reduce it to at most 2 secs.

Is there a faster alternative that is not memory
intensive? There will be times probably where I will need
to read 70/80 rows from the database.

Here is my code:

Dim Counter As Integer = 0
Dim bColorFromDB, fColorFromDB As String
gMyCommand.CommandText = "Select ItemText,
ForeGround,Background, ListNo from ListItems"

gRdr = gMyCommand.ExecuteReader
Dim NewStr As String

While (Counter < 16 And gRdr.Read())
bDo_PaintBackGround = False
m = Frm2.Panel1.Controls(Counter)

'Read the Button color setting from the
'database field backgroundColor

m.Text = gRdr.GetString(0)
fColorFromDB = gRdr.GetInt32(1)
bColorFromDB = gRdr.GetInt32(2)

If fColorFromDB = 1 Then
m.ForeColor = Color.FromArgb(0, 0, 0)
ElseIf fColorFromDB = 2 Then
m.ForeColor = Color.FromArgb(0, 0, 168)
ElseIf fColorFromDB = 3 Then
m.ForeColor = Color.FromArgb(0, 168, 0)
Else

End If


If bColorFromDB = 1 Then
m.buttonImg = m.MakeBitmap(0, 0, 0,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 0
m.RgbB = 0
ElseIf bColorFromDB = 2 Then
m.buttonImg = m.MakeBitmap(0, 0, 168,
m.Height)
m.RgbR = 0
m.RgbG = 0
m.RgbB = 168
ElseIf bColorFromDB = 3 Then
m.buttonImg = m.MakeBitmap(0, 168, 0,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 168
m.RgbB = 0
Else

End If

bDo_PaintBackGround = True
Frm2.Panel1.Controls(Counter).Refresh()
Counter += 1
End While



Thanks in advance.

.
 
S

Serg Kuryata [MS]

Have you tried to populate a DataTable with data from the database and then
read information from the table?

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Zahid" <[email protected]>
| Sender: "Zahid" <[email protected]>
| References: <[email protected]>
| Subject: Controls mapped to Database
| Date: Fri, 10 Oct 2003 07:32:32 -0700
| Lines: 98
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOPO1dMm0Gy1nvbST+usCeR5S5UoA==
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:35680
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi,
|
| Any ideas anyone? Hope so.
|
|
| >-----Original Message-----
| >Hi,
| >
| >I have a SQLServerCE database linked to my PocketPC
| >application. What i am doing is reading a row of data
| >from a table and assigning the values from that row to a
| >custom control (picture button). The rows in the
| database
| >table contain the configuration setting of the custom
| >designed picture button such as background color,
| >foreground colour, text etc.
| >
| >I have about 16 of these custom controls on my form and
| >the user will regularly need to refresh these so as to
| >read new picture button settings from the database. The
| >problem im having is that the refresh speed is a little
| >slow (4 secs)- causing a delay for the user. I would
| like
| >to reduce it to at most 2 secs.
| >
| >Is there a faster alternative that is not memory
| >intensive? There will be times probably where I will
| need
| >to read 70/80 rows from the database.
| >
| >Here is my code:
| >
| > Dim Counter As Integer = 0
| > Dim bColorFromDB, fColorFromDB As String
| > gMyCommand.CommandText = "Select ItemText,
| >ForeGround,Background, ListNo from ListItems"
| >
| > gRdr = gMyCommand.ExecuteReader
| > Dim NewStr As String
| >
| > While (Counter < 16 And gRdr.Read())
| > bDo_PaintBackGround = False
| > m = Frm2.Panel1.Controls(Counter)
| >
| > 'Read the Button color setting from the
| > 'database field backgroundColor
| >
| > m.Text = gRdr.GetString(0)
| > fColorFromDB = gRdr.GetInt32(1)
| > bColorFromDB = gRdr.GetInt32(2)
| >
| > If fColorFromDB = 1 Then
| > m.ForeColor = Color.FromArgb(0, 0, 0)
| > ElseIf fColorFromDB = 2 Then
| > m.ForeColor = Color.FromArgb(0, 0, 168)
| > ElseIf fColorFromDB = 3 Then
| > m.ForeColor = Color.FromArgb(0, 168, 0)
| > Else
| >
| > End If
| >
| >
| > If bColorFromDB = 1 Then
| > m.buttonImg = m.MakeBitmap(0, 0, 0,
| > m.Width, m.Height)
| > m.RgbR = 0
| > m.RgbG = 0
| > m.RgbB = 0
| > ElseIf bColorFromDB = 2 Then
| > m.buttonImg = m.MakeBitmap(0, 0,
| 168,
| > m.Width,
| m.Height)
| > m.RgbR = 0
| > m.RgbG = 0
| > m.RgbB = 168
| > ElseIf bColorFromDB = 3 Then
| > m.buttonImg = m.MakeBitmap(0, 168,
| 0,
| > m.Width, m.Height)
| > m.RgbR = 0
| > m.RgbG = 168
| > m.RgbB = 0
| > Else
| >
| > End If
| >
| > bDo_PaintBackGround = True
| > Frm2.Panel1.Controls(Counter).Refresh()
| > Counter += 1
| > End While
| >
| >
| >
| >Thanks in advance.
| >
| >.
| >
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top