none
Tally ERP Integration with .NET RRS feed

All replies

  • Assuming that you all know Tally ERP and TDL

    here's the two strategies that can be used to connect with the Tally ERP 

    http://mirror1.tallysolutions.com/Downloads/TDL%20Developer/Tally.ERP%209%20-%20Integration%20Capabilities.pdf

    1. Integration using XML interface.
    2. Integration using  ODBC Driver.

     



    • Edited by SKracker Tuesday, January 17, 2012 5:58 AM
    Tuesday, January 17, 2012 5:52 AM
  • if you use XML 

    objXml.open "POST", "http://localhost:9000", False

    objXml.send XMLToPost

     

    objXML="<ENVELOPE><HEADER><VERSION>1</VERSION><TALLYREQUEST>Import </TALLYREQUEST><TYPE>Data</TYPE><ID>All Masters</ID></HEADER><BODY></BODY></ENVELOPE>"

    response = ServerHTTP.responseText

    and you'll get result in response

     

    • Edited by SKracker Tuesday, January 17, 2012 6:15 AM
    Tuesday, January 17, 2012 6:12 AM
  • A Collection can be made available to ODBC by following two
    steps procedure
    1.By exposing methods of the Object(s) of the Collection.
    2.By using Collection attribute 'Is ODBC Table
    Exposing Methods to ODBC
    By prefixing '_ to external method(s) of an internal object or method(s) of an external Object can be exposed to ODBC.
    • By default all the methods of the internal objects are exposed to ODBC
    • Only First level methods of an Object can be exposed directly
    Example :
    [#Object : Ledger]
    _Difference : $ClosingBalance -$OpeningBalance
    The code snippet alters an internal object, Ledger, to add an external method, _Difference and
    exposes it to ODBC.
    Exposing Collections to ODBC
    A Collection is exposed to ODBC by using the attribute, IsODBCTable.
    Example :
    [Collection : Vouchers]
    Type : Voucher
    Is ODBCTable: Yes
    The Collection Vouchers is exposed to ODBC by using the attribute IsODBCTable.
    after doing that you can use either of
    TallyCn ADODB.Connection;
    TallyCn = New ADODB.Connection();
    TallyCn.Open ("TallyODBC_9000");
    ADODB.Recordset rst = New ADODB.Recordset();
    rst.Open ("Select $Name From Ledger", TallyCn, adOpenDynamic, adLockOptimistic);
    OR

    objCmd.ActiveConnection = TallyCn;
    objCmd.CommandType = adCmdStoredProc;
    objCmd.CommandText = "_PartyBills";
    //'Pass the the Stock Item Name as Parameter
    objCmd.CreateParameter (ODBCMAIN.CmbLedger.Text);
    //'Call the SQL procedure
    DataSet objRs = objCmd.Execute();
    Tuesday, January 17, 2012 6:43 AM
  • <pre lang="x-cpp">using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.Data.Odbc;
    using System.Net;
    using System.IO;
    using System.Data.SqlClient;
    using System.Data.SqlTypes;
    //using MSXML2;
    namespace TallyDataTest
    {
        class TallyXml
        {
            private static string RequestXML = "<ENVELOPE><HEADER><TALLYREQUEST>Export Data</TALLYREQUEST></HEADER><BODY><EXPORTDATA><REQUESTDESC><REPORTNAME>List of Accounts</REPORTNAME><STATICVARIABLES><SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT><ACCOUNTTYPE>All Inventory Masters</ACCOUNTTYPE></STATICVARIABLES></REQUESTDESC></EXPORTDATA></BODY></ENVELOPE>";
            private static WebRequest TallyRequest;// = WebRequest.Create("http://192.168.0.96:9000");
            //private static ServerXMLHTTP30 RequestClient=new ServerXMLHTTP30();
            public static DataSet ConnectToTally()
            {
                RequestXML = "<ENVELOPE><HEADER><TALLYREQUEST>Export Data</TALLYREQUEST></HEADER><BODY><EXPORTDATA><REQUESTDESC><REPORTNAME>List of Accounts</REPORTNAME><STATICVARIABLES><SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT><ACCOUNTTYPE>All Inventory Masters</ACCOUNTTYPE></STATICVARIABLES></REQUESTDESC></EXPORTDATA></BODY></ENVELOPE>";
                TallyRequest = WebRequest.Create("http://192.168.0.96:9000");
                ((HttpWebRequest)TallyRequest).UserAgent = ".NET Framework Example Client";
                // Set the Method property of the request to POST.
                TallyRequest.Method = "POST";
                // Create POST data and convert it to a byte array.
                string postData = RequestXML;
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                // Set the ContentType property of the WebRequest.
                TallyRequest.ContentType = "application/x-www-form-urlencoded";
                // Set the ContentLength property of the WebRequest.
                TallyRequest.ContentLength = byteArray.Length;
                // Get the request stream.
                Stream dataStream = TallyRequest.GetRequestStream();
                // Write the data to the request stream.
                dataStream.Write(byteArray, 0, byteArray.Length);
                // Close the Stream object.
                dataStream.Close();
                // Get the response.
                WebResponse response = TallyRequest.GetResponse();
                // Display the status.
                string Response=(((HttpWebResponse)response).StatusDescription).ToString();
                // Get the stream containing content returned by the server.
                dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromTallyServer = reader.ReadToEnd().ToString();
                
                // Display the content.
                //string ResponseFromtally=responseFromServer.ToString();
                
                DataSet TallyResponseDataSet = new DataSet();
                TallyResponseDataSet.ReadXml(new StringReader(responseFromTallyServer));
    // Clean up the streams.
                reader.Close();
                dataStream.Close();
                response.Close();
                byteArray = null;
                response = null;
                responseFromTallyServer = null;
                Response = null;
                dataStream = null;
                // RequestClient.open("Get", "http://localhost:9000/", false, null, null);
               // RequestClient.send(
               // IXMLDOMNode ResponseXml = (IXMLDOMNode)RequestClient.responseXML;
                return TallyResponseDataSet;
            }
    
        }
    }
    
    With the Returned DATA SET we can DO wonders....
    I'll show how to use it in the next reply...
    
    Thursday, January 19, 2012 11:54 AM
  •  private void button1_Click(object sender, EventArgs e)
            {
                DataSet TallyCollectionDataSet =TallyDataTest.TallyXml.ConnectToTally();
    
                TallyGridView.DataSource = TallyCollectionDataSet.Tables["GODOWN"];
       
                
                TallyGridView.AutoGenerateColumns = true;
                TallyGridView.Visible = true;
                
            }
    


    in a form if you have button click event you can bind it to your Data-Grid view...

    Happy coding...

    Thursday, January 19, 2012 11:59 AM
  • Thanks for sharing

    Friday, January 20, 2012 6:00 AM
  • What I found out was...

    1>The XML Request and response was fast and can be done across diffrent clients which dosen't need ODBC Driver..

    2>you can also connect to the Tally with the help of OTHER LANGUAGES such as java....

    These are tips for XML Request and Response...

    • Please make sure tally server is open at http://localhost:portno if not check this
    • Configure Tally Server to act as Both Server and the Client (In Advance Configuration of tally (F 12))
    • Give Correct IP Address and Port no.

    For ODBC Connection 

    • Be Careful you cannot connect the Tally Data Base across different client in simple if you use ODBC driver it doesn't mean the Tally is acting as Server...
    • one more thing you need to provide the following code below...
    [Collection : Inventory]
    Type : Stock Items
    Is ODBCTable: Yes
    • save the file as .txt and add it in Tally config or in  TDL Configuration and give the source of the file
    • STILL IT DOSEN'T MEAN YOU GOT ACCESS TO WHOLE OF TALLY DB
    • it just means Inventory data is accessible (though No modification possible).
    • as Developer point of view ODBC has advantages like it's very fast for deployment and Tally SQL Query's are efficient and concise.
    • use the (.NET) plugin at the tally server to retrieve data from local machine and make that plugin as the Web-Service so that it can be used effectively across different client machine...

     

    Friday, January 27, 2012 11:54 AM
  • FOR ODBC 

     

    //Tally will automaticallly create System DSN and user DSN if you add TDL code file in Tally config file/ TDL Configuration in Tally
    
    //"Dsn=TallyODBC_9000;uid=Administrator;pwd=admin"
    

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.Data.Odbc;
    
    namespace TallyDataTest
    {
        class TallyOdbc
        {
            private static OdbcConnection TallyCollectionConnection = new OdbcConnection("Dsn=TallyODBC_9000;uid=Administrator;pwd=admin");
            public static DataSet ConnectToTally()
            {
                TallyCollectionConnection.Open();
                OdbcCommand TallyCommand = new OdbcCommand("SELECT StockItem.$Name, StockItem.$Parent FROM TESTER.TallyUser.StockItem ORDER BY StockItem.$Name", TallyCollectionConnection);
                OdbcDataAdapter TallyDataAdapter = new OdbcDataAdapter(TallyCommand);
                DataSet TallyDataSet = new DataSet();
                //TallyDataAdapter.Fill(TallyDataSet);
                TallyDataAdapter.Fill(TallyDataSet);
                TallyCollectionConnection.Close();
                return TallyDataSet;            
            }
    
        }
    }
    
    //Similarly data set returned can be used as shown above...
    

    • Edited by SKracker Friday, January 27, 2012 12:02 PM <STRONG>
    Friday, January 27, 2012 12:02 PM
  • Thanks a lot for example, it saved lot of effort for me. Thanks a ton buddy.

    Sunday, April 1, 2012 3:31 PM
  • vote helpfull if it really helps you...

    $Kracker

    Wednesday, April 18, 2012 10:51 AM
  • hey the above code is for retrieving data from tally na????

    pls reply

    i want to retrieve data from sql server and integrate in tally

    pls help me

    thank you

    Saturday, July 21, 2012 6:21 AM
  • Dear RutujaS,

    Extremely sorry for the late reply, here I'll give you directions you gotta try it out

    1. Use the SqlClient and Odbc from System.Data Namespace in C# Windows or console application on some event you execute the method in the class where you'll retrieve the data from SQL and put it into the Tally
    2. From SqlClient you can retrive the Data in form of the DataSet/DataTable
    3. As Tally ODBC doesn't provide you the support for Inserting record so try the XML integration
    4. I've provided the function for sending the data in form of XML to the Tally in above post please follow the steps and voila you've got yourselves the data you wanted from SQL to Tally

    $Kracker


    • Edited by SKracker Monday, August 13, 2012 11:23 AM
    Monday, August 13, 2012 11:20 AM
  • How can I retrieve the list of ledgers in a particular company ?
    Wednesday, August 15, 2012 1:27 PM
  • class abc{

    DataSet ds=new DataSet();

    ds=TallyXml.GetTallyData()

    }

    class TallyXml
        {
            private static string RequestXML;
            private static WebRequest TallyRequest;
            //private static ServerXMLHTTP30 RequestClient=new ServerXMLHTTP30();
            public static DataSet GetTallyData()
            { 
              RequestXML = "<ENVELOPE><HEADER><TALLYREQUEST>Export Data</TALLYREQUEST></HEADER><BODY><EXPORTDATA><REQUESTDESC><REPORTNAME>List of Accounts</REPORTNAME><STATICVARIABLES><SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT><ACCOUNTTYPE>Ledgers</ACCOUNTTYPE></STATICVARIABLES></REQUESTDESC></EXPORTDATA></BODY></ENVELOPE>";

                TallyRequest = WebRequest.Create("http://localhost:9000");
                ((HttpWebRequest)TallyRequest).UserAgent = ".NET Framework Example Client";
                // Set the Method property of the request to POST.
                TallyRequest.Method = "POST";
                // Create POST data and convert it to a byte array.
                string postData = RequestXML;
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                // Set the ContentType property of the WebRequest.
                TallyRequest.ContentType = "application/x-www-form-urlencoded";
                // Set the ContentLength property of the WebRequest.
                TallyRequest.ContentLength = byteArray.Length;
                // Get the request stream.
                Stream dataStream = TallyRequest.GetRequestStream();
                // Write the data to the request stream.
                dataStream.Write(byteArray, 0, byteArray.Length);
                // Close the Stream object.
                dataStream.Close();
                // Get the response.
                WebResponse response = TallyRequest.GetResponse();
                // Display the status.
                string Response = (((HttpWebResponse)response).StatusDescription).ToString();
                // Get the stream containing content returned by the server.
                dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromTallyServer = reader.ReadToEnd().ToString(); 
                DataSet TallyResponseDataSet = new DataSet();
                TallyResponseDataSet.ReadXml(new StringReader(responseFromTallyServer));
                // Clean up the streams.
                reader.Close();
                dataStream.Close();
                response.Close();
                byteArray = null;
                response = null;
                responseFromTallyServer = null;
                Response = null;
                dataStream = null;
                // RequestClient.open("Get", "http://localhost:9000/", false, null, null);
                // RequestClient.send(
                // IXMLDOMNode ResponseXml = (IXMLDOMNode)RequestClient.responseXML;






                return TallyResponseDataSet;
            }

        }

                                      
    Thursday, October 18, 2012 11:03 AM
  • This is by far the most comprehensive webpage on Tally and .NET integration apart from tallysolutions! although I know this, it took me a long long time to find out. This is really helpful.

    PL

    Wednesday, December 5, 2012 11:36 AM
  • Hi +SKracker & others,

    Any idea how to do the below? I tried but it just wouldn't work

    1) Date queries - For eg. I want to get all Sales Vouchers between Date 1 and Date 2

    2) Joins - I want to get data from 2 or more tables using one query. For eg. I want list of sales vouchers along with the party group name

    I am using

    Tally.ERP 9, C#, ODBC, Win 7

    Thanks!


    PL

    Thursday, December 6, 2012 12:14 PM
  • Hi SKracker,

       I tried to extract Tally data using ODBC method. I could not able to locate any of the transaction/voucher level details from any of the tables retrieved. 

    I need details like, voucher number, voucher particulars, voucher date, ledger belongs to, amount values etc. 

    Am using C#, ADO.Net & SQL Server. Please guide me. 

    Wednesday, June 19, 2013 12:25 PM
  • Hi freinds,

    How to create Addon's for tally like Sending SMS directly from Tally Application itself.

    Plz Help in this regards

    Thanks in Advance... 

    Monday, February 17, 2014 7:19 AM
  • can you help me for retrieve voucher details 
    Friday, May 16, 2014 7:47 PM
  • You can write tdl using tally developer.

    Regards

    Yogendra

    www.tallyworld.com


    Tuesday, December 16, 2014 6:17 PM
  • Hmm... Sorry for the delayed reply but I wonder if you can do data queries for tally ,what i think you can do is get the data and then query if you want to

    Thanks


    $Kracker

    Wednesday, April 1, 2015 8:31 AM
  • you can't do it from .NET, you have those functionality in Tally ERP itself

    Thanks,


    $Kracker


    • Edited by SKracker Wednesday, April 1, 2015 8:32 AM
    Wednesday, April 1, 2015 8:32 AM
  • if we want to store this dataset into ms sql server what should we do?
    Thursday, April 19, 2018 8:10 AM
  • hi everyone,

    just want to check what is the best way of integrating with TALLY.

    XML or ODBC?

    <g class="gr_ gr_275 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="275" id="275">i</g> want all transactions from my software to be reflected automatically to TALLY.

    thanks

    Monday, July 9, 2018 5:21 PM
  • i am getting the following response and my enter is not posted in tally...

    <!DOCTYPE html><html><body><RESPONSE>License server is Running<br><br><b>Product : </b>Tally.ERP 9<br><b>Serial number : </b>755658801<br><b>License state : </b> Permanent License<br><br><b>Product : </b>Tally.Developer 9<br><b>Serial number : </b>(Not Applicable)<br><b>License state : </b> No License<br><br><b>Product : </b>Shoper 9<br><b>Serial number : </b>(Not Applicable)<br><b>License state : </b> No License<br><br><b>Product : </b>Tally.Server 9<br><b>Serial number : </b>(Not Applicable)<br><b>License state : </b> No License<br></RESPONSE></body></html>

    Why i am getting the above response every time i am importing data...

    this is my code...

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace TallyIntegration
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void SubmitBut_Click(object sender, EventArgs e)
            {
                Ledger ledger = new Ledger()
                {
                    ledgerName = LadgerNameTextBox.Text,
                    groupName = GroupTextBox.Text,
                    openingBalance = OpeningBalanceTextBox.Text
                };

                LedgerCreateXml(ledger);
            }

            public class Ledger
            {
                public Ledger() { }
                public string ledgerName { get; set; }
                public string groupName { get; set; }
                public string openingBalance { get; set; }
            }

            public string SendReqst(string pWebRequstStr)
            {
                String lResponseStr = "";
                String lResult = "";
                string responseFromTallyServer;
                try
                {
                    string lTallyLocalHost = "http://localhost:9999";
                    WebRequest httpWebRequest = WebRequest.Create(lTallyLocalHost);
                    ((HttpWebRequest)httpWebRequest).UserAgent = ".NET Framework Example Client";
                    httpWebRequest.Method = "POST";

                    string postData = pWebRequstStr;
                    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                    httpWebRequest.ContentType = "application/x-www-form-urlencoded";
                    httpWebRequest.ContentLength = pWebRequstStr.Length;

                    Stream dataStream = httpWebRequest.GetRequestStream();
                    dataStream.Write(byteArray, 0, byteArray.Length);
                    dataStream.Close();

                    WebResponse response = httpWebRequest.GetResponse();
                    string Response = (((HttpWebResponse)response).StatusDescription).ToString();
                    dataStream = response.GetResponseStream();
                    StreamReader reader = new StreamReader(dataStream);
                    responseFromTallyServer = reader.ReadToEnd().ToString();

                   

                    reader.Close();
                    dataStream.Close();
                   
                }
                catch(Exception)
                {
                    throw;
                }
                lResult = responseFromTallyServer;
                return lResult;

            }

            private void button1_Click(object sender, EventArgs e)
            {
               
            }

            public void LedgerCreateXml(Ledger ledger) // request xml and response for ledger creation
            {
                try
                {
                    String xmlstc = "";
                    xmlstc = "<ENVELOPE>\r\n";
                    xmlstc = xmlstc + "<HEADER>\r\n";
                    xmlstc = xmlstc + "<TALLYREQUEST>Import Data</TALLYREQUEST>\r\n";
                    xmlstc = xmlstc + "</HEADER>\r\n";
                    xmlstc = xmlstc + "<BODY>\r\n";
                    xmlstc = xmlstc + "<IMPORTDATA>\r\n";
                    xmlstc = xmlstc + "<REQUESTDESC>\r\n";
                    xmlstc = xmlstc + "<REPORTNAME>All Masters</REPORTNAME>\r\n";

                    xmlstc = xmlstc + "<STATICVARIABLES>\r\n";
                    xmlstc = xmlstc + "<SVCURRENTCOMPANY>TallyIntegration</SVCURRENTCOMPANY>\r\n";
                    xmlstc = xmlstc + "</STATICVARIABLES>\r\n";

                    xmlstc = xmlstc + "</REQUESTDESC>\r\n";
                    xmlstc = xmlstc + "<REQUESTDATA>\r\n";
                    xmlstc = xmlstc + "<TALLYMESSAGE xmlns:UDF=" + "\"" + "TallyUDF" + "\">\r\n";

                    xmlstc = xmlstc + "<LEDGER NAME=" + "\"" + ledger.ledgerName + "\">\r\n"; //"\" Action =" + "\"" + "Create" + "\">\r\n";
                    xmlstc = xmlstc + "<NAME>" + ledger.ledgerName + "</NAME>\r\n";
                    xmlstc = xmlstc + "<PARENT>" + ledger.groupName + "</PARENT>\r\n";
                    xmlstc = xmlstc + "<OPENINGBALANCE>" + ledger.openingBalance + "</OPENINGBALANCE>\r\n";
                  //  xmlstc = xmlstc + "<ISBILLWISEON>Yes</ISBILLWISEON>\r\n";
                    xmlstc = xmlstc + "</LEDGER>\r\n";

                    xmlstc = xmlstc + "</TALLYMESSAGE>\r\n";
                    xmlstc = xmlstc + "</REQUESTDATA>\r\n";
                    xmlstc = xmlstc + "</IMPORTDATA>\r\n";
                    xmlstc = xmlstc + "</BODY>";
                    xmlstc = xmlstc + "</ENVELOPE>";
                    String xml = xmlstc;
                    String lLedgerResponse = SendReqst(xml);
                    LadgerNameTextBox.Text = lLedgerResponse;
                    MessageBox.Show(lLedgerResponse);
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }



        }
    }

    Monday, September 3, 2018 9:57 AM
  • Hi, Thanks for guidance, but one problem, when you connect Tally through IP Address (http://192.168.0.96:9000) but  in production how i detect client IP address and if i got, then how it connected to different series IP like in your case it is 0 and how you connect to 
    http://192.168.3.96:9000 IP address, i think it's not accessable.
    Tuesday, September 1, 2020 11:56 AM
  • Here how i connect to a perticular system's tally means an individual persons tally

    is that by userid and password ? please guide me.

    Tuesday, September 1, 2020 12:00 PM
  • Hi, please tell me how i connect with different system tally by using IP or account Id please guide me i am waiting for you reply.
    Wednesday, September 2, 2020 6:11 PM
  • Hi, Here in place of http://localhost:9000/ what can we give, for which it connect with different persons system where tally installed.
    Wednesday, September 2, 2020 6:19 PM