Databases and Records (recordsets)

Questions regarding syntax

Databases and Records (recordsets)

Postby andyf » Mon Feb 07, 2011 2:00 pm

Hi

I have been using Realbasic for a while but have never really felt comfortable with it.
I downloaded and am trying the latest version of KBasic.

My problem is regarding MySQL databases ( built in database engine) and records.

In realbasic the following code works, but I am struggling to find clear documentation
on how to code this in KBasic.

newrecord = New DatabaseRecord

newrecord.Column("name")="Name"
newinvoice.column("address")="address"
newinvoice.DateColumn("date")=date
newinvoice.CurrencyColumn("amount")=val(listbox1.text)

databasename.insertrecord "invoices" , newrecord

databasename.commit


I have changed `newrecord = New DatabaseRecord` to newrecord = New record` which seems to work but I cannot
get the code to populate a field of the record to work, and am yet to try to insert a record into database.
I realise that in KBasic the database name is not needed, just the table name.

Can someone show me the KBasic equivelant code please.

Regards
andyf
andyf
 
Posts: 3
Joined: Mon Feb 07, 2011 1:22 pm

Re: Databases and Records (recordsets)

Postby Henning » Mon Feb 07, 2011 2:26 pm

Hi,

Personally I dislike ready-made built-in DB's. Handle the DB using Recordsets. Don't know if this is to any help...

http://www.kbasic.com/forum/viewtopic.php?f=12&t=583

Just forgot, lookout for fieldnames that are commands or tpyenames. The DB-handler in KB somehow seems to interpret fieldnames. Filednames like "Data" causes problems.

/Henning
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden

Re: Databases and Records (recordsets)

Postby andyf » Mon Feb 07, 2011 8:25 pm

Thanks

I did load up your example code, and read many forum posts before posting, but I was still unsure how to use a Record and read/write to a SQL database
I'll go through the posts and examples again and see if I can figure it out.

Thanks again for your reply.

Regards
andyf
andyf
 
Posts: 3
Joined: Mon Feb 07, 2011 1:22 pm


Return to Coding Questions

cron