Wednesday, January 18, 2006

weird vb6 or mysql(5) ?

weird vb6/mysql construct for the day

this causes automation error:

If RS.Fields("IsAuthorized").Value = 1 Then

'note: when database is ms sql, the above error doesn't occur

the following is the work-around for mysql 5

If CInt(RS.Fields("IsAuthorized").Value) = 1 Then

-----------------

another weird in mysql

Dim IsAuthorized As Boolean
IsAuthorized = Rs.Fields("IsAuthorized").Value = 1

Dim IsAuthorized As Boolean
IsAuthorized = CInt(Rs.Fields("IsAuthorized").Value) = 1

--------------------

conclusion:
seems mysql doesn't have datatype for recordset's field, explicit type cast must be needed

0 Comments:

Post a Comment

<< Home