|
|
 |
Author |
Message |
friendlyware

|
Posted: Thu Sep 29 09:39:36 CDT 2005 |
Top |
ADO >> Cint(null)
Hi
I have code that stores integer data from the control to the database.
(I am using Option Strict). The problem is when I try to do the code
below, I get that the string is not properly formatted because there is
no value. Each page has a lot of variables. Is there a way to solve
that problem without having to have an IF block for each variable?
myNewRow("score1") = CInt(SCORE1.Text)
Thanks
W
DotNet100
|
|
|
|
 |
Peter

|
Posted: Thu Sep 29 09:39:36 CDT 2005 |
Top |
ADO >> Cint(null)
> Hi
>
> I have code that stores integer data from the control to the database.
> (I am using Option Strict). The problem is when I try to do the code
> below, I get that the string is not properly formatted because there is
> no value. Each page has a lot of variables. Is there a way to solve
> that problem without having to have an IF block for each variable?
>
> myNewRow("score1") = CInt(SCORE1.Text)
>
> Thanks
> W
>
Yes, you do need to evaluate the input in interface objects before
attempting conversions.
What you describe is an input failure where the user failed to enter
anything into the textbox, correct?
You need to add code to trap missing/inappropriate input and force the user
to enter the correct stuff *before* you attempt any conversions or storage
in your database.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
|
|
|
|
 |
Wael

|
Posted: Thu Sep 29 11:26:59 CDT 2005 |
Top |
ADO >> Cint(null)
That' sad.
|
|
|
|
 |
cecil

|
Posted: Thu Sep 29 15:05:19 CDT 2005 |
Top |
ADO >> Cint(null)
Wael,
Do your db fields allow nulls? Or do you want to default to zero
( or int.Max or whatever) if the Score1.Text is null. If you want null
to become a default value then create a global function in a module or
a shared method of a utility class:
public function FixNull(str as string,int nullVal) as integer
If str is null then
FixNull = nullVal
Else
FixNull = Cint(str)
End if
End Function
Now your code can use FixNull in place of CInt.
You may also deal with if str is not numeric but chances are you want
the exception to escape.
Cecil Howell
MCT, MCSD, MCAD.NET, MCDFSWQZ
|
|
|
|
 |
Wael

|
Posted: Thu Sep 29 20:33:53 CDT 2005 |
Top |
ADO >> Cint(null)
I did something similar to that. I have a global function that takes
the datarow and the value and sets it accordingly
|
|
|
|
 |
|
|