-1

I am getting the error "\r\n Could not set 'SVCurrentCompany' to 'ECAPWEB'\r\n\r\n" from tally.

I have used a dot.net code to import data to tally but is giving me this error. I was able to integrate it preveously but now I am getting the above error does anyone know when does this error come

The code I used is

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>" + DIMP + " </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=" + "\"" + name + "\" Action =" + "\"" + "Create" + "\">\r\n";
                            xmlstc = xmlstc + "<NAME>" + name + "</NAME>\r\n";
                            xmlstc = xmlstc + "<PARENT>" + "Sundry Debtors" + "</PARENT>\r\n";
                            xmlstc = xmlstc + "<OPENINGBALANCE>" + balance + "</OPENINGBALANCE>\r\n";
                            xmlstc = xmlstc + "<ADDRESS.LIST TYPE=\"String\">\r\n";
                            foreach (var item in str)
                            {
                                xmlstc = xmlstc + "<ADDRESS>" + item + "</ADDRESS>\r\n";
                            }
                            xmlstc = xmlstc + "</ADDRESS.LIST>\r\n";
                            xmlstc = xmlstc + "<LEDSTATENAME>" + state + "</LEDSTATENAME>\r\n";
                            xmlstc = xmlstc + "<PINCODE>" + pincode + "</PINCODE>\r\n";
                            xmlstc = xmlstc + "<PARTYGSTIN>" + gst + "</PARTYGSTIN>\r\n";

                            xmlstc = xmlstc + "<GSTREGISTRATIONTYPE>Regular</GSTREGISTRATIONTYPE>\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);

                            string myXml = lLedgerResponse;
                            XmlDocument doc = new XmlDocument();
                            doc.LoadXml(myXml);`

I cheched the code & company name every thing is fine

sai vineeth
  • 891
  • 2
  • 5
  • 11

1 Answers1

1

Based on your code it's difficult to know the reason for error as you didn't posted full code or xml you are using

Based on your code you are trying to create a ledger you can use Tally Connector Library which is opensource and available as nugget also.

Once you installed TallyConnector use below code to create ledger

Add these usings

using TallyConnector.Core.Models;
using TallyConnector.Core.Models.Masters;
using TallyConnector.Services;

Add below code

TallyService tally = new();
Ledger ledger = new();
ledger.Name = "test";
ledger.OpeningBal = 5000;
ledger.State = "State";
ledger.PinCode="500062";
PostRequestOptions requestOptions = new();
requestOptions.Company = "Company Name";
TallyResult Response = await tally.PostLedgerAsync(ledger,requestOptions);

sai vineeth
  • 891
  • 2
  • 5
  • 11
  • I tried this but its giving Response as Id = 231, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}" And the data is not getting inserted – Chintan Chheda Mar 06 '23 at 10:33
  • I had tried my code it was working fine for single user of Tally but I want to add data to a multilicense tally and the tally company file I have kept in c drive. So do you know which changes I need to do so that tally catches the xml request. Anyways thanks a lot for your help. – Chintan Chheda Mar 06 '23 at 10:42
  • 1
    You didn't added await. before tally.PostLedgerAsync(ledger,requestOptions); – sai vineeth Mar 07 '23 at 03:22
  • 1
    Xmls will work irrespective of environment.(single or multi), keeping file in data path is not sufficient., you need to keep company open in Tally – sai vineeth Mar 07 '23 at 03:23
  • 1
    Thanks a lot for help but now I figured out the problem. Problem was the ODBC port and tally gatway port were different that was causing problem. The nugget package is very nice I wish I had know it before but now I have developed the whole code which I require. – Chintan Chheda Mar 09 '23 at 12:16
  • ok, If you like nugget, you can star the repo. – sai vineeth Mar 10 '23 at 07:22