how to check if textbox value is a multiple of a field in a database
Posted on 2007-08-11
I am using VB.Net 2005 SP1 Compact Framework 2.0 with MS SQL Server 2005 Compact.
I have a textbox called txtD that only accepts integers. I need to know how to compare that value to a value in field t_adc in tblTally and determine if txtD is a multiple of t_adc.
for example if t_adc = 3 then txtD would have to be 3, 6, 9, 12, 15 ...etc to be valid.
another example if t_adc = 2 then txtD would have to be 2, 4, 5, 8, 10...etc to be valid
How would I do that? See my code below to help me finish it off. I left a message where I need help.
Dim ssceconn As New SqlCeConnection("Data Source = \Program Files\data\products.sdf"
Dim readerCT As SqlCeDataReader
Dim cmdCT As New SqlCeCommand("SELECT t_adc FROM tblTally WHERE t_albl = 'Spec'", ssceconn)
Dim dc As Integer
readerCT = cmdCT.ExecuteReader
dc = CInt(readerCT.Item("t_adc").ToString)
' Close the connection
readerCT = Nothing
ssceconn = Nothing
If txtD.Text is multiple of dc Then ' THIS IS WHERE I NEED HELP