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 » U++ Library support » U++ SQL » date not showing in sqlarray
date not showing in sqlarray [message #52300] Mon, 02 September 2019 03:45 Go to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

Hi all-

I am practicing U++. I am having trouble with dates in sqlbool with sqlset situations and also just plain sqlarray.query() commands.. It returned the ID and location just fine.

If anyone has a quick moment can you please take a gander at this small snippet of code and tell me why when I call query of the sqlarray it does not return the date in the sqlarray control?

Code follows: THNX! roboloki

#include "fearmonger.h"
 
#include <CtrlLib/CtrlLib.h>
 
using namespace Upp;

struct WinDlg : public WithWin10Layout<TopWindow>  {
    Button button;
    SqlCtrls ctrls;
    EditInt myid;
    EditDate mydate;
    EditString myloc;
   
    typedef WinDlg CLASSNAME;
   
    void exec4() {
    SqlBool where;
    SqlBool where2;
    WinDlg dlg;
   
 // SQL * Select(dlg.ctrls).From(SCHEDULE).Where(ID == 3);
    disturbed.Query();
   
 }
   
    WinDlg() {
        
    CtrlLayout(*this, "computer");
    
    Title("My application with menu").Sizeable();
       
    Add(button.LeftPos(10, 100).TopPos(10, 30));  
    disturbed.SetTable(SCHEDULE);
    disturbed.AddKey(ID);
    disturbed.AddColumn(ID,"ID").Edit(myid);
    disturbed.AddColumn(LOCATION,"loc").Edit(myloc);
    disturbed.AddColumn(START_DATE, "START_DATE").Edit(mydate);
    disturbed.Appending().Inserting().Removing();
    button <<= THISBACK(exec4);
    }  
  };
    
void Cyborg::SqArray(){
	
  WinDlg dlg;
  dlg.Run();
 //  menu.Set(THISBACK(WinDlg());  

	
}


sqlite> pragma table_info(SCHEDULE);
0|ID|INTEGER|0||1
1|LOCATION|STRING|0||0
2|START_DATE|INTEGER|0||0
3|START_TIME|INTEGER|0||0
4|END_DATE|INTEGER|0||0
5|END_TIME|INTEGER|0||0
6|DESCRIPTION|STRING|0||0
Re: date not showing in sqlarray [message #52301 is a reply to message #52300] Mon, 02 September 2019 03:51 Go to previous messageGo to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

sqlite> select * from schedule;
1|||2019-08-26 18:52:23||2019-08-26 18:52:23|
2|||2019-08-26 18:54:01||2019-08-26 18:54:01|
3|||2019-08-26 19:00:02||2019-08-26 19:00:02|
4|z||2019-08-31 11:01:05||2019-08-31 11:01:05|x
Re: date not showing in sqlarray [message #52303 is a reply to message #52300] Mon, 02 September 2019 18:06 Go to previous messageGo to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

Hi all-

I noticed I left out some conversion magic. Here is my attempt at getting the dates to appear in the sqlarray control. They still do not show up! I am out foraging for tips. Please chime in. THNX ROBOLOKI

#include "fearmonger.h"
 
#include <CtrlLib/CtrlLib.h>
 
using namespace Upp;

struct DateIntConvertCls : Convert {
    virtual Value Format(const Value& q) const;
    virtual Value Scan(const Value& text) const;
    virtual int Filter(int chr) const;
};
 
Value DateIntConvertCls::Format(const Value& q) const
{
    return IsNull(q) ? String() : ::Format(Date(1970, 1, 1) + (int)q);
}
 
Value DateIntConvertCls::Scan(const Value& text) const
{
    String txt = text;
    if(IsNull(txt))
        return Null;
    Date d;
    if(StrToDate(d, txt))
        return d - Date(1970, 1, 1);
    return ErrorValue("Invalid date!");
}
 
int DateIntConvertCls::Filter(int chr) const
{
    return CharFilterDate(chr);
}
 
Convert& DateIntConvert()
{
    return Single<DateIntConvertCls>();
}
struct WinDlg : public WithWin10Layout<TopWindow>  {
    Button button;
    SqlCtrls ctrls;
    EditInt myid;
    EditDate mydate;
    EditString myloc;
   
    typedef WinDlg CLASSNAME;
   
    void exec4() {
    SqlBool where;
    SqlBool where2;
    WinDlg dlg;
   
 // SQL * Select(dlg.ctrls).From(SCHEDULE).Where(ID == 3);
    disturbed.Query();
   
 }
   
    WinDlg() {
        
    CtrlLayout(*this, "computer");
    
    Title("My application with menu").Sizeable();
       
    Add(button.LeftPos(10, 100).TopPos(10, 30));  
	disturbed.SetTable(SCHEDULE);
    disturbed.AddKey(ID);
    disturbed.AddColumn(ID,"ID").Edit(myid);
    disturbed.AddColumn(LOCATION,"loc").Edit(myloc);
    disturbed.AddColumn(START_DATE, "START_DATE").SetConvert(DateIntConvert());   
    disturbed.Appending().Inserting().Removing();
    button <<= THISBACK(exec4);
    }  
  };
    
void Cyborg::SqArray(){
	
  WinDlg dlg;
  dlg.Run();
 //  menu.Set(THISBACK(WinDlg());  

	
}
 


index.php?t=getfile&id=5898&private=0
  • Attachment: no-dates.PNG
    (Size: 4.57KB, Downloaded 288 times)
Re: date not showing in sqlarray [message #52304 is a reply to message #52300] Mon, 02 September 2019 19:08 Go to previous messageGo to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

Hi all-

It seems for the sql array query to work you have to have all the fields defined.

It is working now.

Sorry.

thanks. ROBOLOKI
Re: date not showing in sqlarray [message #52305 is a reply to message #52300] Mon, 02 September 2019 19:22 Go to previous message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

hi AGAIN-

Just wanted to pass along that now the sqlbool and sqlset is working.

Thanks for making this cool project.

ROBOLOKI
Previous Topic: formatting time to pass to sqlite
Next Topic: Compile error on Linux
Goto Forum:
  


Current Time: Thu Mar 28 15:20:07 CET 2024

Total time taken to generate the page: 0.01254 seconds