[Gambas-user] Adding values to fields in SQLite table??
acidblue
sunblaster5 at ...626...
Thu Aug 9 06:25:27 CEST 2012
Ahh I like that idea!
I 'm now using Gambas 3 ;)
When you say make module do you mean make an actual module(Right
click>>new>>module)
or can i add this code to the FMain form??
CODE
Public sub Main()
Connections["MyConnection"].Open
End
Fabien Bodard-4 wrote:
>
> 2012/8/8 Adam Ant <adamnt42 at ...626...>
>
>> On Wed, Aug 8, 2012 at 2:59 PM, Fabien Bodard <gambas.fr at ...626...>
>> wrote:
>> > Le 8 août 2012 04:49, "Adam Ant" <adamnt42 at ...626...> a écrit :
>> >> The answer is:
>> >>
>> > It's create
>> >> rTable=$hConn.create("Inventory",<some request to get the record you
>> >> want to update>)
>> >> IF rTable.Available then
>> >> rTable!name=txtName.Text
>> >> rTable.Update
>> >> END IF
>> >>
>> >
>> > Don't open/ close the db each time
>> >
>>
>> Yes, sorry Roko (and Fabien), I forgot you were trying to ADD a new row.
>>
>> So it's really
>> rTable=$hConn.Create("Inventory")
>> IF rTable.Available then
>> rTable!name=txtName.Text
>> TRY rTable.Update
>> IF ERROR THEN
>> ' your update failed, possibly because of a duplicate key
>> ENDIF
>> END IF
>>
>>
>>
> THen if you want to modify a specific line :
>
> rTable=DB.Edit("Inventory", "id=&1", varId)
>
> rTable!name=txtName.Text
>
> rTable.Update
> db.commit
>
>
> Another thing, If your app use only one db with one connection, Open it on
> start
>
> for exemple your project begin on a module Main.module
>
>
> 'module
> Private hCon as New Connection
> Public Sub Main()
> hCOn.TYpe= "sqlite"
> hCon.Name="Mydb"
> hCon.Host=user.home
> hCon.Open
>
> FormMyMain.Show
> END
>
>
> In FormMyMain do
>
> PUblic sub Form_Close()
>
> db.close
>
> end
>
>
>
>
> Public sub Button_Click()
>
> dim rTable as result
> rTable = db.find("mytable")
> for each rTable
> print rTable!name
> next
> end
>
>
>
>
>
>
>
> in gambas 3 you can use ide to define connections of the project...
>
> you can then use it in the project ... so main.module become :
>
>
> Public sub Main()
>
> Connections["MyConnection"].Open
>
> End
>
> If you use a mysql or other table with password.
>
> You need to add that befor :
>
> Conections["MyConnection"].Password="yourpassword"
>
>
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
>
>
> --
> Fabien Bodard
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
--
View this message in context: http://old.nabble.com/Adding-values-to-fields-in-SQLite-table---tp34267924p34275043.html
Sent from the gambas-user mailing list archive at Nabble.com.
More information about the User
mailing list