SQL statement in datasource.

lallemand
Member Posts: 15
Hi,
I would like to specifie a sql statement in the datasource of a forms and i don't know how to do.
I would like to specifie a sql statement in the datasource of a forms and i don't know how to do.
LALLEMAND Michaël
Service Informatique
Tél. 03 84 91 24 50
Fax. 03 84 91 24 51
Service Informatique
Tél. 03 84 91 24 50
Fax. 03 84 91 24 51
0
Comments
-
HI,
please tell us what you want to achieve with the SQL-statement. Maybe it can be achieved without SQL.Best regards
Lars0 -
that's my init method of my forms :
Query query;
QueryBuildDatasource qbs;
super();
query = new query() ;
qbs = query.addDataSource(tablenum(InventTrans));
qbs.name(inventTrans_ds.name());
qbs.addSortField(fieldNum(inventTrans,Direction));
qbs.addRange(fieldNum(inventTrans,Direction)).value(queryValue(InventDirection::Issue));
qbs.fields().addField(fieldNum(inventTrans,qty),SelectionField::SUM);
//qbs.fields().addField(fieldnum(inventTrans,DatePhysical));
qbs.orderMode(OrderMode::GROUPBY);
inventTrans_ds.query(query);
I want to display the month + the year of the DatePhysical and group by the result.LALLEMAND Michaël
Service Informatique
Tél. 03 84 91 24 50
Fax. 03 84 91 24 510 -
Hi,
Correct me if I dont understand your problem well. I presume that InventTrans table is your forms datasource and thereby the field DatePhysical already is there. Anyway, in your code you add the table as datasource.
The DatePhysical is of the type ETD DatePhysical. This ETD has some properties DateYear, DateMonth and DateDay. If you set the last(DateDay) to "Day not shown", doesn't that solve the problem?Best regards
Lars0 -
no
i would like to code a statement like that :
qbs.fields().addField(fieldnum(inventTrans,DatePhysical),mthofyr(DatePhysical) + "/" + year(DatePhysical));
and i want this result :
03/2006 5
04/2006 -3
05/2006 65
....LALLEMAND Michaël
Service Informatique
Tél. 03 84 91 24 50
Fax. 03 84 91 24 510 -
Okay,
I understand. I think it is something like below:
void init()
{
InventTrans tblInventTrans;
Str dateStr;
Int intmth;
Int intyear;
;
super();
while select DatePhysical from tblInventTrans
group by DatePhysical
asc
{
intmth = mthofyr(tblInventTrans.DatePhysical);
intyear = year(tblInventTrans.DatePhysical);
dateStr = int2str(intmth)+ "/" +int2str(intyear);
info(strfmt("Month and year of transaction: %1", dateStr));
dateStr = "";
}
}
I hope you can use my answer.Best regards
Lars0 -
But i have to display this information in a form's datagrid and not in a dialogbox.
In a report that's easy but in forms i don't know how to do.
Thanks for your help.LALLEMAND Michaël
Service Informatique
Tél. 03 84 91 24 50
Fax. 03 84 91 24 510 -
Hi again,
is it in new form the result should be shown?Best regards
Lars0 -
yes
In the inventable form, i made a menuItem wich call a new form with the itemid in parameters(already make).
In this new form i want to display all inventtrans with sum of quantity and group by month (in a datagrid).LALLEMAND Michaël
Service Informatique
Tél. 03 84 91 24 50
Fax. 03 84 91 24 510 -
Hi again,
have you found a solution to your problem?Best regards
Lars0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions