Hi,
I got error when i try to retrieve data from excel file in using ajax setting update control. When I do not use ajax setting update control, I can retrieve data from excel.
Please kindly suggest me any config i need to change or RadAjax is not supporting data retrieving from excel ?
my codes are as follow.
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
onajaxrequest="RadAjaxManager1_AjaxRequest" clientevents-onrequeststart="startProgress" clientevents-onresponsereceived="hideProgress">
<clientevents onrequeststart="startProgress" />
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btnUpload">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="grvServiceList" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
using (OleDbConnection connExcel = new OleDbConnection(strExlConn))
{
OleDbCommand cmdExcel = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter();
cmdExcel.Connection = connExcel;
connExcel.Open();
DataTable dtExcelSchema;
dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
connExcel.Close();
//string sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString(); //dtExcelSchema.Rows[0]["TABLE_NAME"];
string sheetName = string.Empty;
for (int i = 0; i < dtExcelSchema.Rows.Count; i++)
{
sheetName = sheetName + ", " + dtExcelSchema.Rows[i]["TABLE_NAME"].ToString();
}
DataSet ds = new DataSet();
string SheetName = "Sheet1$";//dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmdExcel.CommandText = "SELECT '" + JobId + "' AS [JobId], * From [" + SheetName + "]";
da.SelectCommand = cmdExcel;
da.Fill(ds);
if (cmdExcel != null) cmdExcel.Dispose();
if (da != null) da.Dispose();
if (connExcel != null) connExcel.Dispose();
//ds.Clear();
//ds.Dispose();
return ds.Tables[0];
}
I got error when i try to retrieve data from excel file in using ajax setting update control. When I do not use ajax setting update control, I can retrieve data from excel.
Please kindly suggest me any config i need to change or RadAjax is not supporting data retrieving from excel ?my codes are as follow.
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
onajaxrequest="RadAjaxManager1_AjaxRequest" clientevents-onrequeststart="startProgress" clientevents-onresponsereceived="hideProgress">
<clientevents onrequeststart="startProgress" />
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btnUpload">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="grvServiceList" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
using (OleDbConnection connExcel = new OleDbConnection(strExlConn))
{
OleDbCommand cmdExcel = new OleDbCommand();
OleDbDataAdapter da = new OleDbDataAdapter();
cmdExcel.Connection = connExcel;
connExcel.Open();
DataTable dtExcelSchema;
dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
connExcel.Close();
//string sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString(); //dtExcelSchema.Rows[0]["TABLE_NAME"];
string sheetName = string.Empty;
for (int i = 0; i < dtExcelSchema.Rows.Count; i++)
{
sheetName = sheetName + ", " + dtExcelSchema.Rows[i]["TABLE_NAME"].ToString();
}
DataSet ds = new DataSet();
string SheetName = "Sheet1$";//dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
cmdExcel.CommandText = "SELECT '" + JobId + "' AS [JobId], * From [" + SheetName + "]";
da.SelectCommand = cmdExcel;
da.Fill(ds);
if (cmdExcel != null) cmdExcel.Dispose();
if (da != null) da.Dispose();
if (connExcel != null) connExcel.Dispose();
//ds.Clear();
//ds.Dispose();
return ds.Tables[0];
}