데이터베이스에서 데이터 테이블을 통해 데이터를 반환하는 Webservice를 사용 중이며 데이터 테이블을 바이트 배열로 변환합니다. 프런트 엔드에서는 bytearray를 datatable로 변환하고 ajaxloader를 사용하여 폼에 표시합니다. 동적로드입니다. 따라서 각 클릭에 대해 데이터 크기에 관계없이 데이터를 검색하는 데 10 초가 걸립니다. 그래서, 정적 데이터 테이블을 사용하고 페이지로드 이벤트에서 해당 데이터 테이블의 모든 데이터를로드했습니다. 하지만, 아무 반응. 그것은 단지 같은 시간을 가지고 있습니다. 다시 조사 할 데이터가 없어도 ajax 로더가 10 초 동안로드됩니다. Ajax 또는 웹 서비스에 문제가 있습니까 ?? Plz, 나에게 다른 생각을 말해? !!데이터베이스에서 데이터 로딩 속도를 높이는 방법
다음과 같이 listboxclick 이벤트에 대한 나의 코드
protected void listboxcity_SelectedIndexChanged(object sender, EventArgs e)
{
string sqlvalue = string.Empty;
//Thread.Sleep(200);
for (int i = 0; i < listboxcity.Items.Count; i++)
{
if (listboxcity.Items[i].Selected == true)
sqlvalue += listboxcity.Items[i].ToString() + ",";
}
if (sqlvalue.EndsWith(","))
{
sqlvalue = sqlvalue.Remove(sqlvalue.Length - 1);
}
txtprefcity.Text = sqlvalue;
if (txtprefcity.Text != string.Empty)
{
listboxarea.Items.Clear();
txtprefarea.Text = "";
try{
string[] strarea = txtprefcity.Text.ToString().Split(',');
foreach (String s in strarea)
{
DataTable dtarea = new DataTable();
DataTable dt = bc.ConvertByteToDataTable(objservice.GetData("getdistrictbyname", new object[] { s }));
foreach (DataRow r in dt.Rows)
dtarea = bc.ConvertByteToDataTable(objservice.GetData("getarea", new object[] { int.Parse(r["countryid"].ToString()), int.Parse(r["stateid"].ToString()), int.Parse(r["districtid"].ToString()) }));
foreach (DataRow rw in dtarea.Rows)
{
listboxarea.Items.Add(rw["areaname"].ToString());
}
}
}
catch (Exception ex)
{
ObjLog.Write(ex.Message);
}
}
}
웹 방법은 다음과 같습니다 그것은 이 소리 질문에서
public byte[] GetData(string StoredProcedureName, params object[] ParameterValues)
{
GC.Collect();
using (SqlConnection MyConnection = new SqlConnection(connectionstring))
{
using (SqlCommand MyCommand = new SqlCommand(StoredProcedureName, MyConnection))
{
using (SqlDataAdapter MyAdapter = new SqlDataAdapter())
{
MyConnection.Open();
MyCommand.CommandType = CommandType.StoredProcedure;
MyAdapter.SelectCommand = MyCommand;
SqlCommandBuilder.DeriveParameters(MyCommand);
int Index = 0;
foreach (SqlParameter Parameter in MyCommand.Parameters)
{
if (Parameter.Direction == ParameterDirection.Input || Parameter.Direction == ParameterDirection.InputOutput)
{
if (ParameterValues[Index] != null)
{
if (ParameterValues[Index].ToString() != string.Empty)
{
Parameter.Value = ParameterValues[Index];
}
else
{
Parameter.Value = DBNull.Value;
}
}
else
{
Parameter.Value = DBNull.Value;
}
Index++;
}
}
using (DataTable ds = new DataTable())
{
MyAdapter.Fill(ds);
MyConnection.Close();
return convertdatatabletobytearray(ds);
}
}
}
}
}
게시 됨 내 코드 .. 매우 간단한 쿼리뿐입니다. 데이터도 적습니다 .. 변환을 제거해 보았습니다.하지만 동일한 효과가 나타납니다. 아약스 로더에 문제가 있다고 생각하십니까 ?? 하지만 아약스 없이는 사용할 수 없다. – Nila