[Gambas-user] invalid object error on variable of database queries
Dimitris Anogiatis
dosida at ...626...
Thu Oct 8 22:36:12 CEST 2009
Vasilis,
if I'm reading your code correctly you're closing the result set before you
use rsAPOD!arithmosAp
you could assign the value of rsAPOD!arithmosAp in a variable and use that
in the print statement
or move MODMain.$Con.Close below the CLOSE hPrinter line.
that way the resultset can close properly.
I hope this helps
Regards,
Dimitris
On Thu, Oct 8, 2009 at 1:50 PM, Vassilis K <vkan53 at ...2300...> wrote:
> Hello again,
>
> I have a strange little problem with my database (Mysql) queries.
> I make many queries and updates together with the click of a button.
>
> When I make the queries and updates without using any of the results then
> everything works fine !!
> When I want to use a part of the results I get the invalid object error and
> all of the results turn to red ( do not work).
>
> AT the example below I get the error message "invalid object" at the PRINT
> #hPrinter line and the problem is on the rsAPOD!arithmosAp result which is
> LongInteger (at the end of the PRINT line).
>
> here is the code:
>
> PUBLIC SUB Kataxwrisi_Click()
> DIM hPrinter AS File
> DIM $Result5 AS Result
> DIM $ResultAPOD AS Result
> DIM rsAPOD AS Result
> DIM rsGRAMMI AS Result
> DIM $ResultE5 AS Result
> DIM TrexousaGrammi AS Long
> DIM proigoumenos AS Long
>
> MODMain.Connect
> MODMain.$Con.Begin()
> $Result5 = MODMain.$Con.Create("BiblioPortas")
> $Result5!trexousaHmerominia = Date(Now)
> $Result5!Poson = Val(TextBox2.Text)
> $Result5.Update()
> MODMain.$Con.Commit()
>
>
>
> MODMain.Connect()
> rsAPOD = MODMain.$Con.exec("select * from AApodixi order by
> arithmosAp desc")
> MODMain.$Con.Close
>
>
> MODMain.Connect
> MODMain.$Con.Begin()
> $ResultE5 = MODMain.$Con.Create("Ektyposis")
> $ResultE5.Update()
> MODMain.$Con.Commit()
>
> MODMain.Connect()
> rsGRAMMI = MODMain.$Con.exec("select * from Ektyposis order by
> Grammi desc")
> TrexousaGrammi = rsGRAMMI!Grammi
> MODMain.$Con.Close
>
> hPrinter = OPEN "/dev/lp1" FOR OUTPUT
> hPrinter.EndOfLine = gb.Windows
>
> PRINT #hPrinter, "Anaxorisi" & " " & Format$(Date(Now), "dd.mm.yyyy") & "
> A/A " & tArithmos.Text & " " & tEpitheto.Text & " " & tOnoma.Text & " " &
> tEthnikotita.Text & " " & "Poson " & TextBox2.Text & " Ar.Apodixis " &
> rsAPOD!arithmosAp
>
> IF TrexousaGrammi MOD 55 = 0 THEN
> PRINT #hPrinter, Chr$(12);
> PRINT #hPrinter, " "
> PRINT #hPrinter, " "
> PRINT #hPrinter, " "
> PRINT #hPrinter, " "
> ENDIF
> CLOSE hPrinter
>
>
> MODMain.Connect
> MODMain.$Con.Begin()
> 'MODMain.$Con.exec("UPDATE `pelates`.`egrafes` SET
> `anaxwrisi` = '" & Date(Now) & "' WHERE `egrafes`.`AA` = '" &
> tArithmos.Text &
> "' LIMIT 1 ")
> MODMain.$Con.exec("UPDATE `pelates`.`egrafes` SET
> `egrafes`.`epitheto` = '" & tEpitheto.Text &
>
> "',........................................etc...................................',
> `egrafes`.`timifix` = '" & CFloat(ttimifix.Text) & "' WHERE `egrafes`.`AA`
> =
> '" & tArithmos.Text & "' LIMIT 1 ")
> MODMain.$Con.exec("UPDATE `pelates`.`egrafes` SET
> `egrafes`.`ekptosi` = '" & tekptosi.Text & "', `egrafes`.`elenchosAnax` =
> 1,
> `egrafes`.`xreosi` =0, `egrafes`.`prokatavoli` = '" &
> CFloat(tprokatavoli.Text) & "' WHERE `egrafes`.`AA` = '" & tArithmos.Text &
> "'
> LIMIT 1 ")
> MODMain.$Con.Close
>
> MODMain.Connect
> MODMain.$Con.Begin()
> $ResultAPOD = MODMain.$Con.Create("AApodixi")
> $ResultAPOD!Hmerominia = Date(Now)
> $ResultAPOD!arithmosAp = rsAPOD!arithmosAp + 1
> $ResultAPOD.Update()
> MODMain.$Con.Commit()
>
> ME.Close
> END
>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list