title: how to create new ledger in tally using C#
body: <p>I want to write C# code to create new ledger in Tally database .I am  developing an ERP using ASP.Net MVC . I want to integrate the application with Tally. So that the Ledger data would be transferred as XML format to the Tally. How to do this? I need all your valuable contributions.here is my code</p>
  
  <pre><code>string strGRNDate = "2/02/2014";
                  string strVoucherNo = "3";
                  string strGRNNo = "2";
                  string strSupplierName = "Abhinav Sharma";
                  string strPurchaseOrder = "2";
                  string strGRN = "1";
                  string strGRNValueNtv = "2";
  
  
                  xmlstc = "&lt;ENVELOPE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;HEADER&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;TALLYREQUEST&gt;Import Data&lt;/TALLYREQUEST&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/HEADER&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;BODY&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;IMPORTDATA&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;REQUESTDESC&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;REPORTNAME&gt;Vouchers&lt;/REPORTNAME&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;STATICVARIABLES&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;SVCURRENTCOMPANY&gt;##SVCURRENTCOMPANY&lt;/SVCURRENTCOMPANY&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/STATICVARIABLES&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/REQUESTDESC&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;REQUESTDATA&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;TALLYMESSAGE xmlns:UDF=" + "\"" + "TallyUDF" + "\" &gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;VOUCHER VCHTYPE=" + "\"" + "Purchase" + "\" &gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;DATE&gt;" + strGRNDate + "&lt;/DATE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;VOUCHERTYPENAME&gt;Purchase&lt;/VOUCHERTYPENAME&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;VOUCHERNUMBER&gt;" + strVoucherNo + "&lt;/VOUCHERNUMBER&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;REFERENCE&gt;" + strGRNNo + "&lt;/REFERENCE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;PARTYLEDGERNAME&gt;" + strSupplierName + "&lt;/PARTYLEDGERNAME&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;PARTYNAME&gt;" + strSupplierName + "&lt;/PARTYNAME&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;EFFECTIVEDATE&gt;" + strGRNDate + "&lt;/EFFECTIVEDATE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;ISINVOICE&gt;Yes&lt;/ISINVOICE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;INVOICEORDERLIST.LIST&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;BASICORDERDATE&gt;" + strGRNDate + "&lt;/BASICORDERDATE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;BASICPURCHASEORDERNO&gt;" + strPurchaseOrder + "&lt;/BASICPURCHASEORDERNO&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/INVOICEORDERLIST.LIST&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;ALLLEDGERENTRIES.LIST&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;LEDGERNAME&gt;" + strSupplierName + "&lt;/LEDGERNAME&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;GSTCLASS/&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;ISDEEMEDPOSITIVE&gt;No&lt;/ISDEEMEDPOSITIVE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;LEDGERFROMITEM&gt;No&lt;/LEDGERFROMITEM&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;REMOVEZEROENTRIES&gt;No&lt;/REMOVEZEROENTRIES&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;ISPARTYLEDGER&gt;Yes&lt;/ISPARTYLEDGER&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;AMOUNT&gt;" + strGRN + "&lt;/AMOUNT&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;BILLALLOCATIONS.LIST&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;NAME&gt;" + strGRNNo + "&lt;/NAME&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;BILLCREDITPERIOD&gt;30 Days&lt;/BILLCREDITPERIOD&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;BILLTYPE&gt;New Ref&lt;/BILLTYPE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;AMOUNT&gt;" + strGRN + "&lt;/AMOUNT&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/BILLALLOCATIONS.LIST&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/ALLLEDGERENTRIES.LIST&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;ALLLEDGERENTRIES.LIST&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;LEDGERNAME&gt;Abhinav Sharma&lt;/LEDGERNAME&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;GSTCLASS/&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;ISDEEMEDPOSITIVE&gt;Yes&lt;/ISDEEMEDPOSITIVE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;LEDGERFROMITEM&gt;No&lt;/LEDGERFROMITEM&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;REMOVEZEROENTRIES&gt;No&lt;/REMOVEZEROENTRIES&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;ISPARTYLEDGER&gt;No&lt;/ISPARTYLEDGER&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;AMOUNT&gt;" + strGRNValueNtv + "&lt;/AMOUNT&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/ALLLEDGERENTRIES.LIST&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/VOUCHER&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/TALLYMESSAGE&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/REQUESTDATA&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/IMPORTDATA&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/BODY&gt;" + "\r\n";
                  xmlstc = xmlstc + "&lt;/ENVELOPE&gt;" + "\r\n";
  
                  HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:" + Connection.TallyPort);
                  httpWebRequest.Method = "POST";
                  httpWebRequest.ContentLength = xmlstc.Length;
                  httpWebRequest.ContentType = "application/x-www-form-urlencoded";
                  streamWriter = new StreamWriter(httpWebRequest.GetRequestStream());
                  streamWriter.Write(xmlstc);
                  streamWriter.Close();
                  string result;
                  HttpWebResponse objResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                  using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
                  {
                      result = sr.ReadToEnd();
                      sr.Close();
                  }
  </code></pre>
  
  <p>I am getting error at every spot</p>