Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts,
I have a large amount of data displaying in a html table.
On button click using java script json I am sending data row wise to data base using c# code.
For this process it takes around 20 to 30 mins. But I want to make it fat.
So any suggestion will be helpful.
Thank you,
Your follower.
Posted
Comments
Sergey Alexandrovich Kryukov 20-Sep-14 12:11pm    
It is already pretty fat... :-)
—SA
Shibasankar 20-Sep-14 12:43pm    
Sir, I mean any other way can we make it little bit faster?
Sergey Alexandrovich Kryukov 20-Sep-14 12:55pm    
HTML is not the best data source, and Javascript is not the best language for parsing HTML. I don't know why your code works so slowly though, because you did not provide any information on that, and gave no idea how much data is there and how big the files are.
—SA
Sergey Alexandrovich Kryukov 20-Sep-14 12:56pm    
And there is no such thing as "Java script". Java is not a scripting language.
Why did you put C# tag is you are using Javascript?
—SA

Please see my comments to the question.
Consider using this: https://www.npmjs.org/package/htmlparser[^].

See also: http://ejohn.org/blog/pure-javascript-html-parser[^].

Try to do your own search: http://bit.ly/1hmkFs2[^].

But the whole idea to store data in HTML is bad. HTML should be used only to present data to human users. It can be marginally justified only for Web scraping, but such scrapping does not need Javascript, could be done using some compiled language, something depending on your platform.

—SA
 
Share this answer
 
Quote:
I am inserting arount 8000 records at one button click.
Here is my code.
-------------------------------------------------------


function ADDDOCPOSTDetails() {
var BillType = $('input:radio[name=IP_OP_Pharm_All]:checked').val();
var dropdown = document.getElementById("ddlyear");
var index = dropdown.selectedIndex;
var ddlyear = dropdown.options[index].value;
var ddText = dropdown.options[index].text;

var dropdown1 = document.getElementById("ddlmonth");
var index1 = dropdown1.selectedIndex;
var ddlmonth = dropdown1.options[index1].value;
var YearMonth = ddlyear + ddlmonth;
deletedadocpost(YearMonth, BillType);

$("#tbl_ipopbil tr:gt(0)").each(function () {
var th = $(this);
if ($(th).find("input[type='checkbox']").is(":checked")) {
var billno = $(th).find("td:eq(1)").text();
var bildate = $(th).find("td:eq(2)").text();
var mrno = $(th).find("td:eq(3)").text();
var ipno = $(th).find("td:eq(4)").text();
var crdcompcd = $(th).find("td:eq(22)").text();
var patcatgcd = $(th).find("td:eq(23)").text();
var bedcatgcd = $(th).find("td:eq(24)").text();
var tariffid = $(th).find("td:eq(26)").text();
var deptcode = $(th).find("td:eq(20)").text();
var doctcode = $(th).find("td:eq(16)").text();
var servslno = $(th).find("td:eq(8)").text();
var vchrdate = $(th).find("td:eq(25)").text();
var servdate = $(th).find("td:eq(9)").text();
var servcode = $(th).find("td:eq(6)").text();
var servqty = $(th).find("td:eq(10)").text();
var servamt = $(th).find("td:eq(12)").text();
var doctamount = $(th).find("td:eq(19)").text();
var TranType = $(th).find("td:eq(27)").text();
var HospUnit = $(th).find("td:eq(28)").text();
var TranCode = "";
$.ajax({
type: "post",
contentType: "application/json; charset=utf-8",
url: "IPOPBILLSPOSTING.aspx/AddDocPosting",
data: "{'YEARMONTH':'" + YearMonth + "','billno':'" + billno + "','billdate':'" + billdate + "','mrno':'" + mrno + "','ipno':'" + ipno + "','crdcompcd':'" + crdcompcd + "' ," +
"'patcatgcd':'" + patcatgcd + "','bedcatgcd':'" + bedcatgcd + "','tariffid':'" + tariffid + "','deptcode':'" + deptcode + "','doctcode':'" + doctcode + "'," +
"'servslno':'" + servslno + "','vchrdate':'" + vchrdate + "','servdate':'" + servdate + "','servcode':'" + servcode + "','servqty':'" + servqty + "'," +
"'servamt':'" + servamt + "','doctamount':'" + doctamount + "', 'TRANCODE':'" + TranCode + "', 'TRANTYPE':'" + TranType + "', 'HospUnit':'" + HospUnit + "'}",
contentType: "application/json",
dataType: "json",
success: function (data) {
$("#tbody_ipopbill").html("");
ActionStatus("Inserted Sucessfully");
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(xhr.responseText);
alert(thrownError);
}
});
}
});
}

Please check whether it's the correct way or not.
Thank You.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900