|
|
Home » U++ Library support » U++ SQL » date not showing in sqlarray
date not showing in sqlarray [message #52300] |
Mon, 02 September 2019 03:45  |
|
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   |
|
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   |
|
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());
}
-
Attachment: no-dates.PNG
(Size: 4.57KB, Downloaded 388 times)
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 20:32:18 CEST 2025
Total time taken to generate the page: 0.00837 seconds
|
|
|