Desktop version

Main > Forum > Learning > 1C Junior Developer Course > Adding parameter to query

Forum

Search UsersRules
Adding parameter to query
#1
Interested
Points:: 0
Joined:: Sep 30, 2020

User enters a number in a field
System shows that amountPaids which is greater than the number

My code below;

SEL ECT
Sales.Number AS Number,
Sales.Date AS Date,
Sales.AmountPaid AS AmountPaid,
Sales.PaymentMethod AS PaymentMethod
FR OM
Document.Sales AS Sales

WHERE AmountPaid > what I need to write here
ORDER BY AmountPaid DESC

Profile
#2
Administrator
Points:: 0
Joined:: Oct 3, 2019

Mesut,

you need to write something like this:


Code
   Query = New Query;
   Query.Text = 
      "SELECT
      |   Sales.Number AS Number,
      |   Sales.Date AS Date,
      |   Sales.AmountPaid AS AmountPaid,
      |   Sales.PaymentMethod AS PaymentMethod
      |FROM
      |   Document.Sales AS Sales
      |WHERE
      |   Sales.AmountPaid > &Number";
   
   Query.SetParameter("Number", Number);
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();
   
   While SelectionDetailRecords.Next() Do

   EndDo;


Aleksandr

Profile
#3
Active user
Points:: 0
Joined:: May 8, 2013

Hi Mesut,

Please, rewatch this episode of the course. One of the topics is about passing parameter values to a query.

Konstantin

Profile
#4
Interested
Points:: 0
Joined:: Sep 30, 2020

Thank you, I have solved the problem

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.