riskyricky1972
asked on
asp.net c#app_data
has the attached codes working fine, but I do not know how to call on aspx page.
It suppose has while statement to call and loop every rows.
It suppose has while statement to call and loop every rows.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for decisiontable
/// </summary>
public class decisiontable
{
int _bondlistid;
int _countpublicRd;
int _ficoscore;
int _statecode;
int _manualbondamt;
public int bondamt
{
get { return _manualbondamt; }
set { _manualbondamt = value; }
}
public int bondlistid
{
get { return _bondlistid; }
set { _bondlistid = value; }
}
public int countpublicRd
{
get { return _countpublicRd; }
set { _countpublicRd = value; }
}
public int ficoscore
{
get { return _ficoscore; }
set { _ficoscore = value; }
}
public int statecode
{
get { return _statecode; }
set { _statecode = value; }
}
public SqlDataReader viewyearterms
{
get {
SqlConnection pagedbconnection = new SqlConnection();
try
{
string dbconnectionstring = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string commandtext = "decisiontable";
pagedbconnection.ConnectionString = dbconnectionstring;
SqlCommand pagecommand = new SqlCommand(commandtext, pagedbconnection);
pagecommand.CommandType = CommandType.StoredProcedure;
//add parameter
SqlParameter bondlistid_param = new SqlParameter();
bondlistid_param.ParameterName = "@bondlistid";
bondlistid_param.SqlDbType = SqlDbType.Int;
bondlistid_param.Direction = ParameterDirection.Input;
bondlistid_param.Value = _bondlistid;
pagecommand.Parameters.Add(bondlistid_param);
SqlParameter bondamt_param = new SqlParameter();
bondamt_param.ParameterName = "@manualbondamt";
bondamt_param.SqlDbType = SqlDbType.Money;
bondamt_param.Direction = ParameterDirection.Input;
bondamt_param.Value = _manualbondamt;
pagecommand.Parameters.Add(bondamt_param);
pagedbconnection.Open();
SqlDataReader test = pagecommand.ExecuteReader();
return test;
}
catch (Exception ex)
{
//If the exception occurs, handle it
throw (ex);
}
finally
{
//myconnection.close();
pagedbconnection.Close();
}
}
}
}
ASKER
How to call on aspx page?
Go to www.asp.net and work through the databinding examples. They are far better than what I could type here.
ASKER
why don't you show me?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Lead Web Developers: If you do not have time, do not help here. The link you provided does not help to solve my issue. all of my codes are in code behind in app_data with stored procedures. the one you shown me use all different approaches.
NOTE: I did some best practice changes to your code below. If you use the 'using' keyword it automatically disposes an object even if there is an exception.
Also you add overhead to catch an exception then are rethrowing it. That is a waste of effort.
Open in new window