[Gambas-user] Re: Re: casting or changing datatype.

Rohnny Stormo rohnny at ...1248...
Sat Jan 14 20:08:58 CET 2006


Maybee this is what you are looking for
Use a DBClass.. Make a variable....

PRIVATE $Conn AS Connection

Public Function Open() as connection
  $Conn.Name = dbname
  'open the connection.
  $Conn.Open
     return $Conn
end function

PUBLIC FUNCTION Close() AS Boolean
  'Close the database
  TRY $Conn.Close
    RETURN TRUE
  CATCH
    RETURN FALSE
END

PUBLIC FUNCTION SQL($sql AS String) AS Result
  RETURN $Conn.Exec($sql)
END

To use this from a form it should be done like this.
--form1
Private db as new DBClass
Private r as result
Private OtherR as result

sub Form_Open()
    db.open()
    r = db.SQL("select from arcust")
    print r!field1
    print r!field2
    r = db.SQL("select from arcust2")
    print r!field1
    print r!field2
    OtherR = db.SQL("select from arcust4")
    print OtherR!field1
    Print OtherR!field2
    Print "This is still the same as it was before "& r!field1


end sub

-- 
-----------------------------------------
Gambas brings Basic to Linux.
My Gambas Community http://forum.stormweb.no





More information about the User mailing list