Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
I am using ASP.Net frame work 3.5 i get the string query to value to pass the text box it's a sting value I change the value after save the database but previous value will save not change what is the reason and how can save the current value
Posted
Comments
Prosanta Kundu online 9-Jul-10 4:51am    
Please provide for information... code, that is not working. That will be helpful to answering your question.

I don't get how people can ask such strange questions. The answer is, your code is broken. I could make some guesses why, but without seeing what you're doing wrong, it's really impossible for me to say. Do you tell your doctor your leg hurts and refuse to let him see it ?

Have you tried to do anything to fix this ? How well do you know ASP.NET ? Have you used the debugger ? These are all things we'd like to know, to judge your ability to understand our answer, if you give us the code we need to try to offer one.
 
Share this answer
 
Your static method for adding course details is taking a single parameter of type CourseDetailsVO,

no_of_rows_effected = CourseDetailsDA.AddCourseDetails(obj);


but your method actually takes four strings

public static int AddCourseDetails(string cid,string coursecode,string coursedetatils,string status)


If you have an overload that is not shown in the code above that takes the values and passes them along to the method above then you might have inadvertently not converted all the code to use the values passed in to the method. In the method body you set the values to the strings passed in for the first two parameters, but then you switch to setting it to a variable that is not in the method scope unless I missed it (called coursedetailssvo).

command.Parameters.Add("@C_ID", SqlDbType.Int).Value = cid;
command.Parameters.Add("@Course_Code", SqlDbType.VarChar).Value = coursecode;

command.Parameters.Add("@Course_details",SqlDbType.VarChar).Value = coursedetailsvo.course_details;
command.Parameters.Add("@Status",SqlDbType.TinyInt).Value = coursedetailsvo.status;


So if you were expecting it to be set to what you passed into the method parameter ... it wouldn't be.

The overload may not even be calling the method you have above ... that's where I'd start though.

Hope that makes sense.
 
Share this answer
 
v2
C++
Hi thank you for replay my problem is I get the value for  to string query  and set the value for textbox after edit the text box value and save the data but  it not save the current value when I get string query value my store procedure is work  working I below mention the my code plz. Help me



C#
public static int AddCourseDetails(string cid,string coursecode,string coursedetatils,string status)//CourseDetailsVO coursedetailsvo)
{
    int no_of_rows_effected;
    string procedure = "Prc_ST_SaveCourse";


    using (SqlConnection connection = ConnectionManager.GetGrandHotel_DB_Connection())
    {
        SqlCommand command = new SqlCommand(procedure, connection);
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.Add("@C_ID", SqlDbType.Int).Value = cid;
        command.Parameters.Add("@Course_Code", SqlDbType.VarChar).Value = coursecode;
        command.Parameters.Add("@Course_details",SqlDbType.VarChar).Value = coursedetailsvo.course_details;
        command.Parameters.Add("@Status",SqlDbType.TinyInt).Value = coursedetailsvo.status;
        no_of_rows_effected = command.ExecuteNonQuery();
    }
    return no_of_rows_effected;

}



------------------------------------------------------------------------

C++
public partial class Coursedetails : System.Web.UI.Page
{
    CourseDetailsDA Mdb = new CourseDetailsDA();
    CourseDetailsVO cvo = new CourseDetailsVO();

    int cid;
    string tmpcode;
    protected void Page_Load(object sender, EventArgs e)
    {

        //string icode;
        //  string strcourse;
        string courseid;

        CourseDetailsVO coursevo = new CourseDetailsVO();

        courseid = Request.QueryString["cid"];
        if (courseid == null)
        {
            cid = 0;
        }
        else
        {
            cid = int.Parse(courseid);

            fillForm();

        }


    }

    
    protected void CmdSave_Click(object sender, EventArgs e)
    {

        //if (Session["academyid"] != null)
        //{
            int no_of_rows_effected;

            string strcoursecode = txtCoursecode.Text;
            string strcoursedetails = TxtCourseName.Text;

            CourseDetailsVO obj = new CourseDetailsVO();

            obj.p_id = cid;
            obj.course_code = strcoursecode;
            obj.course_details = strcoursedetails;
            obj.status = 1;

            no_of_rows_effected = CourseDetailsDA.AddCourseDetails(obj);


            if (no_of_rows_effected > 0)
            {
                Master.LblSuccessMessageText = "Course Details has been Save Successfully";
                txtCoursecode.Text = "";
                TxtCourseName.Text = "";

            }


        //}
    }
    protected void CmdClear_Click(object sender, EventArgs e)
    {
        txtCoursecode.Text = "";
        TxtCourseName.Text = "";
    }


    protected void fillForm()
    {
        DataSet ds = new DataSet();

        tmpcode = Request.QueryString["cid"];

        ds = cvo.ReturnMasterData("1", tmpcode, "", "");

        DataRow dr = ds.Tables[0].Rows[0];
        txtCoursecode.Text = dr["Course_Code"].ToString();
        TxtCourseName.Text = dr["Course_Details"].ToString();


    }


--------------------------------------------------------------------

C++
public class CourseDetailsVO
{
    CourseDetailsDA bendb = new CourseDetailsDA();

    public CourseDetailsVO()
    {

    }

    public int p_id { get; set; }
    public string course_code { get; set; }
    public string course_details { get; set; }
    public Int16 status { get; set; }


    public DataSet ReturnMasterData(string MasterId, string param1, string param2, string param3)
    {
        CourseDetailsDA MstrDb = new CourseDetailsDA();
        DataSet MstrDat = new DataSet();

        switch (MasterId)
        {
            case "1":

                long tmpBnkId = long.Parse(param1);
                MstrDat = CourseDetailsDA.GetCourseDataByID(tmpBnkId);
                break;

            default:

                MstrDat = new DataSet();
                break;

        }

        return MstrDat;
    }


}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900