RTSlink DLL v1.8 (or higher) comes with a new function SQLRequest()
that allows you to use SQL-SELECT statement to fetch data from Tally Software.
Let us try to understand what it really means.
SQL-SELECT reduces your code
Instead of lengthly XML tags, you can now write concise SQL statements like:-
SQL SELECT Statement
Select $Name, $Closingbalance from Ledger
Retrieves Name and Closing balance from Ledger Master
Select $Name from Company
Retrieves the Name of the Current / Open Company
Select * from Ledger
Retrieves all the fields of Ledger Master
Select $Name from Ledger where name contains "Sales"
Retrieves all Ledger records which contain "Sales" in the Name field
Select $Name, $Parent, $Baseunits, $ClosingBalance, $ClosingValue from StockItem
Retrieves data from StockItem Master
Reduces the processing time
When you use XML tags to fetch Ledger Master, the result-set contains all the fields
of the Ledger table. By using SQL SELECT statement, you can fetch information that
you require. You can also specify any valid condition to filter out records.
Select $Name, $Closingbalance from Ledger where $$IsDr:$ClosingBalance
- $$IsDr is a pre-defined function in Tally Software
- The above SQL statement returns all records from Ledger master which have Debit
You can now use any valid condition to retieve the desired information. The following
code retieves all Ledgers falling under head 'Sundry Debtors'
Select $Name, $ClosingBalance from Ledger where $$IsChildOf:$$GroupSundryDebtors
Calling User-defined procedures
You can also use SQLRequest() to invoke user-defined procedures. Two files RTSv72.tcp
(for Tally 7.2) and RTSv90.tcp (for Tally 9) are provided with licensed version
of RTSlink dll for using the same.
The above statement will fetch all records for the "Cash" Ledger.
C Declaration for SQLRequest() function
Function : SQLRequest()
C Declaration : int __stdcall SQLRequest(LPSTR);
Return Value : Returns 0 on success, otherwise error-code
For more information, refer "
Using SQL SELECT in Visual Basic"
Tally Integration, VB to Tally, SQL SELECT, Tally 7.2, Tally 9