Sql Sum Statement & Export Csv

fatman

Active Member
Licensed User
Longtime User
Hello I am new to BASIC4PPC and I have 2 questions I haven´t been able to solve yet. Even after long searching with google...

1. I have a sqlite-table with values like that:

1,50
1,30
2,10

I want to sum up these values and display the result (4,90) in a label on the screen. I know sql supprts the SUM statement- but so far I have no solution how to implement this with basic4ppc. :BangHead:

2. I want to export this table as an CSV-file.
I read and searched a lot even the docs for sqlite but did not find a clear solution.

Maybe anyone had the same probs in the past and can give me a hint.

Thanks

Fatman
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Something like:
B4X:
    cmd.New1("",con.Value)
    cmd.CommandText = "SELECT SUM(c1) FROM table1"
    reader.New1
    reader.Value = cmd.ExecuteReader
    Msgbox(reader.GetValue(0)) 'gets the single value returned by this query
    reader.Close

2. You can use cmd.ExecuteTable with a select * query.
You will then get a Rable control will all your data. The Table control has a SaveCSV method.
 
Top