Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » sqlarray and sqlite (Trying to use sqlite example but...)
Re: sqlarray and sqlite [message #54854 is a reply to message #54852] Tue, 22 September 2020 17:43 Go to previous messageGo to previous message
jimlef is currently offline  jimlef
Messages: 90
Registered: September 2020
Location: US
Member
mirek wrote on Tue, 22 September 2020 03:08
Your .sch creates

SqlId CUSTOMERS("CUSTOMERS");

struct S_CUSTOMER {
.....
};

SetTable obviously needs CUSTOMERS as parameter....



Yes, I caught that and had corrected it, thank you...

Quote:


Additional suggestion: CustArray is SqlArray, right? In that case it is better to leave fetching the data to

CustArray.Query();


You can also add where condition e.g.:

CustArray.Query(EMAIL == "smith@email.com");


Sql sql(sqlite3);


You do need to specify the session here, as you have assigned a global default session by

SQL = sqlite3;


And it is better to avoid text SQL commands with SqlExp:

	sql.Execute("select * from CUSTOMERS");


sql * SelectAll().From(CUSTOMERS);


see https://www.ultimatepp.org/src$Sql$SqlExp_en-us.html

This way your commands get at least partially checked by C++ compiler and more importantly it avoids SQL injection problem.

Mirek


That URL is perfect - I missed that in my searches obviously... I was wondering how to do more as in my c#:
        public bool Delete(customersTable dc)
        { ...
                //SQL Query to Delete Data from database
                string sql = "DELETE FROM CUSTOMERS WHERE CUST_ID=@id";

                //SQL command to pass the value
                SQLiteCommand cmd = new SQLiteCommand(sql, conn);
                //Passing the value
                cmd.Parameters.AddWithValue("@id", dc.CUST_ID);
                //Open DB Connection
                conn.Open();
                //integer variable
                int rows = cmd.ExecuteNonQuery();
                if(rows>0) //Success
                {
...


Thank you again Smile
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Friends? Cousins? Half-siblings?
Next Topic: how to make an editfield accept only number or date? have any examples in the documentation?
Goto Forum:
  


Current Time: Fri Jul 18 03:45:46 CEST 2025

Total time taken to generate the page: 0.04807 seconds