locked
Application Block display problem RRS feed

  • Question

  • User-513790065 posted

    I am using the following code which asks for the userID, and security question and its answer:

    public partial class secret : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string get_userid = TextBox1.Text;
            string get_security = DropDownList1.Text;
            string get_answer = TextBox3.Text;
            string password = TextBox4.Text;
            
            //DataSet display;
            string display;
            secret1 s = new secret1();
            display=s.sa(get_userid, get_security, get_answer,password);
            //GridView1.DataSource = display;
            //GridView1.DataBind();
          
        }
    }

    public partial class secret : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {


        }

        protected void Button1_Click(object sender, EventArgs e)

        {

            string get_userid = TextBox1.Text;

            string get_security = DropDownList1.Text;

            string get_answer = TextBox3.Text;

            string password = TextBox4.Text;

            

            //DataSet display;

            string display;

            secret1 s = new secret1();

            display=s.sa(get_userid, get_security, get_answer,password);// calls the following class secret1

            //GridView1.DataSource = display;

            //GridView1.DataBind();

          

        }

    }


    public class secret1

    {

    public string sa(string a, string b, string c,string d)

        {

            Database db = DatabaseFactory.CreateDatabase();

            string sdbCommand = "musp_secert";

            DbCommand dbCommand = db.GetStoredProcCommand(sdbCommand);

            //db.AddInParameter(dbCommand, "@Name", DbType.String, s1);

            //db.AddInParameter(dbCommand, "@Last_name", DbType.String, s2);

            //db.AddInParameter(dbCommand, "@ID", DbType.Int32,);

           // db.AddOutParameter(dbCommand, "@maxid", DbType.Int32, 100);


            db.AddInParameter(dbCommand, "@UserID", DbType.String, a);

            db.AddInParameter(dbCommand, "@S", DbType.String,b);

            db.AddInParameter(dbCommand, "@Sec", DbType.String, c);

            db.AddOutParameter(dbCommand, "@d", DbType.String, 100);


            db.ExecuteScalar(dbCommand);

            return (string)(db.GetParameterValue(dbCommand, "@d"));

            //DataSet dsCust        

            //return (string)db.ExecuteScalar(dbCommand);

            //return db.ExecuteDataSet(dbCommand);

            //dataGrid1.DataSource = dsCust.Tables[0].DefaultView;

            //return dsCust;

    }

    }



    The above codes do ask for the all parameters but does not display the result in the label control; how can I reslove the above problem?

    Tuesday, May 11, 2010 2:55 AM

All replies

  • User2105407822 posted

    debug the application and add breakpoints inside the class to verify the passed parameters and trace the execution

    Tuesday, May 11, 2010 3:48 AM
  • User-513790065 posted

    Whenever I run the code everything is going fine but, ExecuteScalar is not doing its task.

    Thursday, May 13, 2010 4:41 AM
  • User2105407822 posted

    declare an object then assign the return value to it like:

    Object returnValue;
    returnValue = db.ExecuteScalar(dbCommand);

      return returnValue;


    for more info, read:

    http://msdn.microsoft.com/en-us/library/37hwc7kt%28VS.80%29.aspx

    Thursday, May 13, 2010 10:01 AM