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 » SqlVal to int (Typecast) (Typecasting from sqlval type to other types)
Re: SqlVal to int (Typecast) [message #45224 is a reply to message #45176] Sat, 10 October 2015 01:01 Go to previous messageGo to previous message
Alboni is currently offline  Alboni
Messages: 216
Registered: January 2012
Location: Kajaani, Finland
Experienced Member
Hi, I'm using the same code for MySql and SqLite versions of my program and I'd like to point out that using
ro=sql[0];
can behave rather quirky.. in combination with functions like Sum() or Count()
Depending of which db you use, Count, Sum etc. could be presented as int or a String type. Confusing.

A better way (especially if you would select more than one column) is to use the As function:
UserQuerySql * SqlSelect (SqlCount(MBVARINDEX).As(MBVARINDEX)).From ( PARAMETER );
while ( UserQuerySql.Fetch() )
{
  ro=sql[MBVARINDEX];
}

I also like to use SqlSelect, SqlSum, SqlCount etc. because the other terms are so generic there are often clashes.

[Updated on: Sat, 10 October 2015 01:04]

Report message to a moderator

 
Read Message
Read Message
Read Message icon7.gif
Read Message
Read Message
Read Message
Previous Topic: Help: GetSysTime()
Next Topic: Usage of Iml image data leads to linker error
Goto Forum:
  


Current Time: Fri Jun 20 19:52:12 CEST 2025

Total time taken to generate the page: 0.02929 seconds