MSulchan Darmawan ha scritto:
> Dear all,
>
> Any suggestion to simplify this code ? I had "Expression too complex,
> too many operands" warning :D
> I have 36 fields data to insert.
>
>     sSql = "INSERT INTO refpos (id, idpos, year, month, day, " & 
>                   "r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, " &
>                   "r11, r12, r13, r14, r15, r16, r17, r18, r19, r20, " &
>                   "r21, r22, r23, r24, r25, r26, r27, r28, r29, r30, r31" &
>                    ") VALUES " &
>            "('" & hRes!iddata & "', '" & hRes!idpos & "', '" & hRes!yr & "', 
> '" & hRes!mn & "', '" & hRes!dt & "', '" &
>            hRes!r1 & "', '" & hRes!r2 & "', '" & hRes!r3 & "', '" & hRes!r4 & 
> "', '" & hRes!r5 & "', '" & hRes!r6 & "', '" & hRes!r7 & "', '" & hRes!r8 & 
> "', '" & hRes!r9 & "', '" & hRes!r10 & "', '" & 
>            hRes!r11 & "', '" & hRes!r12 & "', '" & hRes!r13 & "', '" & 
> hRes!r14 & "', '" & hRes!r15 & "', '" & hRes!r16 & "', '" & hRes!r17 & "', '" 
> & hRes!r18 & "', '" & hRes!r19 & "', '" & hRes!r20 & "', '" & 
>            hRes!r21 & "', '" & hRes!r22 & "', '" & hRes!r23 & "', '" & 
> hRes!r24 & "', '" & hRes!r25 & "', '" & hRes!r26 & "', '" & hRes!r27 & "', '" 
> & hRes!r28 & "', '" & hRes!r29 & "', '" & hRes!r30 & "', '" & hRes!r31 &
>             "')"
>   
...forgot an important thing:

       res = db.Create("refpos")      ' append record in table named refpos
       for i = 1 to 31
         res["Res" & i] = ...
       next

I don't understand if you want to duplicate a record or whatever, but 
you can use two different Result (or hResult); anyway, writing things 
that way ("insert into ...") is a pain: you write a lot, you easily 
loose connection between field names and field values, and to mantain 
such code is a pain... :-)

Regards,
Doriano


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to