[Gambas-user] Database Results

Fabien Bodard gambas.fr at ...626...
Sat Sep 11 21:46:28 CEST 2010


like that ?

For each hresult

  print hResult!MyField

next

2010/9/11 tobias <tobiasboe1 at ...20...>:
> hello mailing list,
>
> i am absolutely new to databases in general and so to databases in
> gambas, too. i plan to use sqlite3 and in general i am understanding the
> related stuff part by part but it is very confusing with the different
> classes and i think this complicates my learning process.
> but to my questions now. i want to make a database table just in memory
> to get me a bit closer to this all:
>
> hConnection = NEW Connection
> hConnection.Type = "sqlite3"
> hConnection.Open()
> hTable = hConnection.Tables.Add("test")
> hTable.Fields.Add("id", db.Serial)
> hTable.Fields.Add("name", db.String)
> hTable.PrimaryKey = ["id"]
> hTable.Update()
> hResult = hConnection.Create("test")
>
> and in the following i want to add three names to the database and then
> hResult.Update() them, but how do i create more records than one? (i
> used hResult["name"] = "tobi" to create the first, this works)
>
> the next question.
> i got a result from a database with some records predefined (fields are
> id (serial) and name (string)):
>
> hResult = hConnection.Exec("select * from test")
>
> in a for loop i go through all the records by doing:
>
> FOR iCount = 0 TO hResult.Count - 1 STEP 1
>  hResult.MoveTo(iCount)
>  FOR EACH hField IN hResult.Fields
>    TextArea1.Insert(hResult[hField.Name])
>  NEXT
>  TextArea1.Insert("\n")
>  NEXT
>
> which works also fine but i really don't like the hResult.MoveTo() part
> of this code, isn't there any way to handle this result simply as an
> array? this would solve both problems and i could do database stuff with
> ease?
>
> regards, tobi
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fabien Bodard




More information about the User mailing list