Using Recordsets without kbRecordID

Questions regarding syntax

Using Recordsets without kbRecordID

Postby PMan » Sat Nov 13, 2010 4:17 pm

Hi Henning,

in search of reading data records from MySQL without using kbrecordid I found some codesnippets of yours. Under the topic "Databinding, SQL and kbrecordid" you published the function GetArt. But I don't understand this function complettly.

I think, you defined a class called ADODB for recordsets and functions BOF, EOF, ActiveConnection, CursorLocation, CursorType, Source and Open. It looks like doing in VBA and appear to be nice.

But what is rcArt and how do the class and the functions work?
Can you illuninate me a little bit?
PMan
 
Posts: 145
Joined: Sat Jul 03, 2010 12:31 pm
Location: Switzerland

Re: Using Recordsets without kbRecordID

Postby Henning » Sun Nov 14, 2010 2:12 am

Hi, I'll try.
Don't know if things get clearer or more confusing ;)

Everything is built-in in KBasic, no special classes.

rcArt is a User Defined Type UDT, that has members to store the wanted fields in a rec-set. In C it's a struct.

I then (Dim)(Public) ArtRec(1) As rcArt to make a ReDim-able array of UDT's, to hold the returned number of records. This way all relevant records are read once used in many functions.

In real-life ArtReg is a table for shoes/skies/helmets and so on for a rental-shop at a skicentre.

BOF is taken care of with:
If sRecordsId Then 'If Not (BOF Or EOF)
If Records.First(sRecordsId) Then 'this detects if there is at least one record.
EOF is replaced by:
Loop While Records.Next(sRecordsId)

Just for the record, to create MySQL DB's I use EMS Sql Manager for MySQL Lite (free). To backup/restore MySQL Administrator is my choice.

If more Q's just ask, and I'll see if I can answer...

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

Re: Using Recordsets without kbRecordID

Postby PMan » Sun Nov 14, 2010 6:21 pm

Thank you Henning. I have an other Question. What is "New ADODB.Recordset"?
PMan
 
Posts: 145
Joined: Sat Jul 03, 2010 12:31 pm
Location: Switzerland

Re: Using Recordsets without kbRecordID

Postby Henning » Sun Nov 14, 2010 11:23 pm

Hi again,

Since KB is cross OS capable, ther is no "New ADODB.Recordset, that is a windows-only thing.

In KB I just Connect to a DataBase and use SQL Queries to Read/Write Records from/to Tables. And we don't need the Windows (VB) ODBC Connector.

strSQL = "SELECT * FROM TableName WHERE FieldName = " & anr
sRecordsId = Records.Open(sDatabase, strSQL)
is the way to handle Records in KB.

Also the correct way to set-up to connect to the DB, use: Options = Database.defaultoptions ' "DefaultOptions"


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


Return to Coding Questions

cron