Android Question Table and Maps Question

Richard O'Sullivan

Member
Licensed User
Hi All,

I've been trying to use the RDC to access an MSSQL database and eventually succeeded. An example with the RDC tutorial would have been nice.

I'm confused with the Table and Map Type. I've managed to gain access to MSSQL and using the PrintTable routine in the DBRequestManager I am able to see data in the logs.

I'm trying to retrieve data from SQL and write to SQLite and vice versa.

The DBRequest returns a Table result. How do I access the individual Rows and Fields to be able to write to SQLite? Sorry if this seems silly but I could badly do with a bailout here.

Can someone please provide code to solve the above and also possibly some explanation of the DBRequest Table result. Thanking you in advance.
Richard
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The data is stored in the Rows list.

Each item is an array of objects.

To go over all the rows:
B4X:
For Each Row() As Object In Table.Rows
Log(Row(0)) 'first column
Log(Row(1)) 'second column
Next

The columns Map maps between the column names and the columns ordinals.

Add Log(Table.Columns) and you will see it.
 
Last edited:
Upvote 0

Richard O'Sullivan

Member
Licensed User
Thanks Erel - What a wonderful application B4A really is.

The code I was looking for is listed below which may help other newbies.

<Code>
Dim table As DBResult = reqManager.HandleJob(Job)
Dim rst As List
rst.Initialize
For Each row() As Object In table.Rows
Dim m As Map
Dim i As Int
m.Initialize
i=0
For Each record As Object In row
m.Put(table.Columns.GetKeyAt(i),record)
i=i+1
Next
rst.Add(m)
Next

Log("Job Tag: " & Job.Tag)
DBUtils.InsertMaps(SQL1,"zARDOM",rst) 'and put in new data
Log("finish")
</Code>
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Thanks Erel - What a wonderful application B4A really is.

Yes it is ! Maybe you could edit you code tags to help future viewers .. (nearly got them right) [Code] ....... [/Code]

Cheers
 
Upvote 0
Top