public Boolean GetDataSetProc(string strQuery, OracleParameter[] parameterCollection, out string strError, out XmlDocument xmlSchema, out XmlDocument xmlData)
{
DataSet ds = new DataSet();
xmlSchema = new XmlDocument();
xmlData = new XmlDocument();
if (con.State == ConnectionState.Closed)
con.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = strQuery; //procedure Name
cmd.CommandType = CommandType.StoredProcedure;
cmd.BindByName = true;
OracleDataAdapter orada;
OracleParameter[] parameter = new OracleParameter[6];
if (parameterCollection != null)
{
foreach (OracleParameter param in parameterCollection)
{
if (param != null)
{
cmd.Parameters.Add(param);
}
}
}
orada = new OracleDataAdapter(cmd);
try
{
orada.Fill(ds);
}
catch (Exception ex)
{
throw ex;
}
finally
{
//cmd.Dispose();
if (con.State == ConnectionState.Open)
con.Close();
}
strError = cmd.Parameters["p_error_msg"].Value.ToString();
if (strError == "null")
{
if (ds != null)
{
xmlSchema.LoadXml(ds.GetXmlSchema());
xmlData.LoadXml(ds.GetXml());
}
return true;
}
else
{
strError = cmd.Parameters["p_error_msg"].Value.ToString();
//strError = "Problem in procedure";
return false;
}
}
{
DataSet ds = new DataSet();
xmlSchema = new XmlDocument();
xmlData = new XmlDocument();
if (con.State == ConnectionState.Closed)
con.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandText = strQuery; //procedure Name
cmd.CommandType = CommandType.StoredProcedure;
cmd.BindByName = true;
OracleDataAdapter orada;
OracleParameter[] parameter = new OracleParameter[6];
if (parameterCollection != null)
{
foreach (OracleParameter param in parameterCollection)
{
if (param != null)
{
cmd.Parameters.Add(param);
}
}
}
orada = new OracleDataAdapter(cmd);
try
{
orada.Fill(ds);
}
catch (Exception ex)
{
throw ex;
}
finally
{
//cmd.Dispose();
if (con.State == ConnectionState.Open)
con.Close();
}
strError = cmd.Parameters["p_error_msg"].Value.ToString();
if (strError == "null")
{
if (ds != null)
{
xmlSchema.LoadXml(ds.GetXmlSchema());
xmlData.LoadXml(ds.GetXml());
}
return true;
}
else
{
strError = cmd.Parameters["p_error_msg"].Value.ToString();
//strError = "Problem in procedure";
return false;
}
}
==========================================================
private void Get_Data_Summary(string schemnos, string corpids)
{
try
{
ds = new DataSet();
OracleParameter[] parameter = new OracleParameter[8];
parameter = clsOracleParam.OracleParam();
if (txtDateFrom.Text != "" && txtDateTo.Text != "")
{
parameter[6] = new OracleParameter("P_FromDt", txtDateFrom.Text.Trim());
parameter[7] = new OracleParameter("P_Todt", txtDateTo.Text.Trim());
}
else
{
parameter[6] = new OracleParameter("P_FromDt", null);
parameter[7] = new OracleParameter("P_Todt", null);
}
parameter[6].OracleDbType = OracleDbType.Date;
parameter[6].Direction = ParameterDirection.Input;
parameter[7].OracleDbType = OracleDbType.Date;
parameter[7].Direction = ParameterDirection.Input;
Boolean bstatus = CommonClass.GetDataSetProc("pkg_pkgname.procName", parameter, out errmsg, out xmlSchema, out xmlData);
if (bstatus)
{
if (xmlSchema != null && xmlData != null)
{
ds.ReadXmlSchema(new XmlNodeReader(xmlSchema));
ds.ReadXml(new XmlNodeReader(xmlData));
if (ds.Tables[0].Rows.Count > 0)
{
ViewState["dt1"] = ds.Tables[0];
gvSummary.DataSource = ds.Tables[0];
gvSummary.DataBind();
lbl_war.Text = "";
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, typeof(UpdatePanel), "test1", " $('#summary').css('display', 'block'); ", true);
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, typeof(UpdatePanel), "test1", " $('#details').css('display', 'none'); ", true);
//gvSummary.UseAccessibleHeader = true;
//gvSummary.HeaderRow.TableSection = TableRowSection.TableHeader;
//string script2 = "alertTest();";
//ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "jscript", script2, true);
}
else
{
lbl_war.Text = "Record Not Found";
}
}
else
{
lbl_war.Text = "No Record Found";
gvSummary.DataSource = string.Empty;
gvSummary.DataBind();
}
}
}
catch (Exception ex)
{
lbl_war.Text = ex.Message;
lbl_war.ToolTip = errmsg;
}
finally
{
if (xmlSchema != null && xmlData != null)
{
/// to clear a memory...
ds.Dispose();
ds.Clear();
xmlSchema.RemoveAll();
xmlSchema.RemoveAll();
}
}
}
====================================================
public OracleParameter[] OracleParam()
{
OracleParameter[] parameter = null;
parameter = new OracleParameter[15];
parameter[0] = new OracleParameter("p_error_code", ErrCode);
parameter[0].Direction = ParameterDirection.Output;
parameter[0].OracleDbType = OracleDbType.Double;
parameter[1] = new OracleParameter("p_error_msg", errmsg);
parameter[1].Direction = ParameterDirection.Output;
parameter[1].OracleDbType = OracleDbType.Varchar2;
parameter[1].Size = 30;
parameter[2] = new OracleParameter("p_qry", qy);
parameter[2].Direction = ParameterDirection.Output;
parameter[2].OracleDbType = OracleDbType.Varchar2;
parameter[2].Size = 4000;
parameter[3] = new OracleParameter("p_viewrec", OracleDbType.RefCursor);
parameter[3].Direction = ParameterDirection.Output;
return parameter;
}
No comments:
Post a Comment