sayso36 0 Newbie Poster

Hi Experts -

I have created a edit web form. It does get populated with the appropriate record by using DataReader....
but I would like to modify/edit data and save it so it is updated in the access database.

I have created a SaveIssueButton button and put update sql statement in it. After I change any data in the form and click save button, it doesn't save the changes...I get no errors...but the record is not updated.

Below is my 2 methods: one at page_load I'm populating the web controls with a record. Second method is for SaveIssuButton and what its supposed to do.

Please let me know where I might be going wrong and how to solve it. Is it because the data i'm populating on webform is read only? Not sure.

The Code is below: Thanks in Advanced :)

----1

private void Page_Load(object sender, System.EventArgs e)
    {

        if (Page.IsPostBack == false)
        {
        
        string isID = Request.QueryString["Issueid"];
        int ISID = Convert.ToInt32(isID);

        string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~\\App_Data") + "\\ISSUELOG.mdb";

        OleDbConnection cn = new OleDbConnection(connectString);

        //Open the connection.
        cn.Open();

        //Use a variable to hold the SQL statement.
        string selectString = "SELECT * FROM IssueRecordTable where IssueID="+ISID;

        OleDbCommand cmd = new OleDbCommand(selectString, cn);

        OleDbDataReader reader = cmd.ExecuteReader();
        while (reader.Read())
        {
            IssueIDLabel.Text = reader["IssueID"].ToString();
            JobNumbertxt.Text = reader["JobNumber"].ToString();
            JobProgrammedbyddl.SelectedValue = reader["JobProgrammedby"].ToString();
            VendorProgtxt.Text = reader["VendorProgName"].ToString();
            Statuslbl.Text = reader["Status"].ToString();
            DateOfIssuetxt.Value = reader["DateofIssue"].ToString();
            IssEnteredByddl.SelectedValue = reader["IssEnteredBy"].ToString();
            ReportSourceddl.SelectedValue = reader["ReportSource"].ToString();
            ReporterNametxt.Text = reader["ReporterName"].ToString();
            IssueCategoryddl.SelectedValue = reader["IssueCategory"].ToString();
            IssueCategory2ddl.SelectedValue = reader["IssueDetailCombobox"].ToString();
            IssueCategory3ddl.SelectedValue = reader["IssueDetail2opts"].ToString();
            //OverUnderLB.Rows= reader["QuotaOU"].ToString();
            EstimatedDateTxt.Value = reader["EstimatedDate"].ToString();
            ActualDateTxt.Value = reader["ActualDate"].ToString();
            EstdTimeTxt.Text = reader["EstimatedTime"].ToString();
            ActualTimeTxt.Text = reader["ActualTime"].ToString();
            TimeLateTxt.Text= reader["TimeLate"].ToString();
            NumMinsAwayTxt.Text = reader["IssueDetail3txt"].ToString();
            SeverityLevelddl.SelectedValue= reader["SeverityLevel"].ToString();
            StdGuidVioddl.SelectedValue = reader["StnGdlViolated"].ToString();
            //ResponsibleForErrorLB.Rows = reader["CausedError"].ToString();
            ProgDollarAmounttxt.Text= reader["ProgrammingDollarAmount"].ToString();
            DataConDollarAmounttxt.Text= reader["DataConDollarAmount"].ToString();
            QADollarAmounttxt.Text= reader["QADollarAmount"].ToString();
            RespondentsAffectedtxt.Text = reader["RespondentsAffected"].ToString();
            EscalatedTotxt.Text = reader["EscalatedTo"].ToString();
            QAedddl.SelectedValue = reader["QAed"].ToString();
            //QAedByLB.SelectedValue = reader["WhoQAed"].ToString();
            WhatHappenedtxt.Text = reader["WhatHappened"].ToString();
            WhyDidItHappentxt.Text = reader["WhyDidItHappen"].ToString();
            ActionTakentxt.Text = reader["ActionTaken"].ToString();
            HowtoPreventtxt.Text= reader["HowtoPrevent"].ToString();
            CostDescriptiontxt.Text = reader["CostDescription"].ToString();
            Summarytxt.Text = reader["Summary"].ToString();
            ClosedDatetxt.Value = reader["ClosedDate"].ToString();
            IssueClosedByddl.SelectedValue = reader["ClosedUser"].ToString();
        }
    
        reader.Close();
        cn.Close();
           // MultiViewRBL.SelectedIndex = 0;
                     
        }
      
    }

-----2

protected void SaveIssueButton_Click(object sender, EventArgs e)
    {
        //Create a connection to the local NorthWind database
        OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~\\App_Data") + "\\ISSUELOG.mdb");
  
        con.Open();

        //Build update command
        OleDbCommand cmd = new OleDbCommand("Update IssueRecordTable Set JobNumber =@JobNumber , JobProgrammedby=@JobProgrammedby, VendorProgName=@VendorProgrammerName, Status=@Status,  DateofIssue=@DateOfIssue, IssEnteredBy=@IssueEnteredBy, ReportSource=@ReportSource, ReporterName=@ReportName, IssueCategory=@IssueCategory1, IssueDetailCombobox=@IssueDetail2, IssueDetail2opts=@IssueDetail3, QuotaOU=@OverUnder, EstimatedDate=@EstdDate, ActualDate=@ActualDate, EstimatedTime=@EstdTime, ActualTime=@ActualTime, TimeLate=@TimeLate, IssueDetail3txt=@NumberofMinutesAway, SeverityLevel=@SeverityLevel, StnGdlViolated=@StdGuidVio, CausedError=@ResponsibleforError, ProgrammingDollarAmount=@ProgDollarAmount, DataConDollarAmount=@DataConDollarAmount, QADollarAmount=@QADollarAmount, RespondentsAffected=@RespondentsAffected, EscalatedTo=@EscalatedTo, QAed=@QAed, WhoQAed=@QAby, WhatHappened=@WhatHappened, WhyDidItHappen=@WhyDiditHappen, ActionTaken=@ActionTaken, HowtoPrevent=@HowtoPrevent, CostDescription=@CostDescription, Summary=@Summary, ClosedUser=@ClosedUser, ClosedDate=@ClosedDate where IssueID = @IssueID", con);

        //Use parameters
        //=======
        OleDbParameter parIssueID = cmd.Parameters.Add("@IssueID", SqlDbType.VarChar);
        parIssueID.Value = IssueIDLabel.Text;
        OleDbParameter parJobNumber = cmd.Parameters.Add("@JobNumber", SqlDbType.VarChar);
        parJobNumber.Value = JobNumbertxt.Text;
        OleDbParameter parJobProgrammedby = cmd.Parameters.Add("@JobProgrammedby", SqlDbType.VarChar);
        parJobProgrammedby.Value = JobProgrammedbyddl.SelectedValue;
        OleDbParameter parVendorProgrammerName = cmd.Parameters.Add("@VendorProgrammerName", SqlDbType.VarChar);
        parVendorProgrammerName.Value = VendorProgtxt.Text;
        OleDbParameter parStatus = cmd.Parameters.Add("@Status", SqlDbType.VarChar);
        parStatus.Value = Statuslbl.Text;
        OleDbParameter parDateOfIssue = cmd.Parameters.Add("@DateOfIssue", SqlDbType.VarChar);
        parDateOfIssue.Value = DateOfIssuetxt.Value;
        OleDbParameter parIssueEnteredBy = cmd.Parameters.Add("@IssueEnteredBy", SqlDbType.VarChar);
        parIssueEnteredBy.Value = IssEnteredByddl.SelectedValue;
        OleDbParameter parReportSource = cmd.Parameters.Add("@ReportSource", SqlDbType.VarChar);
        parReportSource.Value = ReportSourceddl.SelectedValue;
        OleDbParameter parReportName = cmd.Parameters.Add("@ReportName", SqlDbType.VarChar);
        parReportName.Value = ReporterNametxt.Text;
        OleDbParameter parIssueCategory1 = cmd.Parameters.Add("@IssueCategory1", SqlDbType.VarChar);
        parIssueCategory1.Value = IssueCategoryddl.SelectedValue;
        OleDbParameter parIssueDetail2 = cmd.Parameters.Add("@IssueDetail2", SqlDbType.VarChar);
        parIssueDetail2.Value = IssueCategory2ddl.SelectedValue;
        OleDbParameter parIssueDetail3 = cmd.Parameters.Add("@IssueDetail3", SqlDbType.VarChar);
        parIssueDetail3.Value = IssueCategory3ddl.SelectedValue;
        OleDbParameter parOverUnder = cmd.Parameters.Add("@OverUnder", SqlDbType.VarChar);
        parOverUnder.Value = OverUnderLB.SelectedValue;
        OleDbParameter parEstdDate = cmd.Parameters.Add("@EstdDate", SqlDbType.VarChar);
        parEstdDate.Value = EstimatedDateTxt.Value;
        OleDbParameter parActualDate = cmd.Parameters.Add("@ActualDate", SqlDbType.VarChar);
        parActualDate.Value = ActualDateTxt.Value;
        OleDbParameter parEstdTime = cmd.Parameters.Add("@EstdTime", SqlDbType.VarChar);
        parEstdTime.Value = EstdTimeTxt.Text;
        OleDbParameter parActualTime = cmd.Parameters.Add("@ActualTime", SqlDbType.VarChar);
        parActualTime.Value = ActualTimeTxt.Text;
        OleDbParameter parTimeLate = cmd.Parameters.Add("@TimeLate", SqlDbType.VarChar);
        parTimeLate.Value = TimeLateTxt.Text;
        OleDbParameter parNumberofMinutesAway = cmd.Parameters.Add("@NumberofMinutesAway", SqlDbType.VarChar);
        parNumberofMinutesAway.Value = NumMinsAwayTxt.Text;
        OleDbParameter parSeverityLevel = cmd.Parameters.Add("@SeverityLevel", SqlDbType.VarChar);
        parSeverityLevel.Value = SeverityLevelddl.SelectedValue;
        OleDbParameter parStdGuidVio = cmd.Parameters.Add("@StdGuidVio", SqlDbType.VarChar);
        parStdGuidVio.Value = StdGuidVioddl.SelectedValue;
        OleDbParameter parResponsibleforError = cmd.Parameters.Add("@ResponsibleforError", SqlDbType.VarChar);
        parResponsibleforError.Value = ResponsibleForErrorLB.SelectedValue;
        OleDbParameter parProgDollarAmount = cmd.Parameters.Add("@ProgDollarAmount", SqlDbType.VarChar);
        parProgDollarAmount.Value = ProgDollarAmounttxt.Text;
        OleDbParameter parDataConDollarAmount = cmd.Parameters.Add("@DataConDollarAmount", SqlDbType.VarChar);
        parDataConDollarAmount.Value = DataConDollarAmounttxt.Text;
        OleDbParameter parQADollarAmount = cmd.Parameters.Add("@QADollarAmount", SqlDbType.VarChar);
        parQADollarAmount.Value = QADollarAmounttxt.Text;
        OleDbParameter parRespondentsAffected = cmd.Parameters.Add("@RespondentsAffected", SqlDbType.VarChar);
        parRespondentsAffected.Value = RespondentsAffectedtxt.Text;
        OleDbParameter parEscalatedTo = cmd.Parameters.Add("@EscalatedTo", SqlDbType.VarChar);
        parEscalatedTo.Value = EscalatedTotxt.Text;
        OleDbParameter parQAed = cmd.Parameters.Add("@QAed", SqlDbType.VarChar);
        parQAed.Value = QAedddl.SelectedValue;
        OleDbParameter parQAby = cmd.Parameters.Add("@QAby", SqlDbType.VarChar);
        parQAby.Value = QAedByLB.SelectedValue;
        OleDbParameter parWhatHappened = cmd.Parameters.Add("@WhatHappened", SqlDbType.VarChar);
        parWhatHappened.Value = WhatHappenedtxt.Text;
        OleDbParameter parWhyDiditHappen = cmd.Parameters.Add("@WhyDiditHappen", SqlDbType.VarChar);
        parWhyDiditHappen.Value = WhyDidItHappentxt.Text;
        OleDbParameter parActionTaken = cmd.Parameters.Add("@ActionTaken", SqlDbType.VarChar);
        parActionTaken.Value = ActionTakentxt.Text;
        OleDbParameter parHowtoPrevent = cmd.Parameters.Add("@HowtoPrevent", SqlDbType.VarChar);
        parHowtoPrevent.Value = HowtoPreventtxt.Text;
        OleDbParameter parCostDescription = cmd.Parameters.Add("@CostDescription", SqlDbType.VarChar);
        parCostDescription.Value = CostDescriptiontxt.Text;
        OleDbParameter parSummary = cmd.Parameters.Add("@Summary", SqlDbType.VarChar);
        parSummary.Value = Summarytxt.Text;
        OleDbParameter parClosedUser = cmd.Parameters.Add("@ClosedUser", SqlDbType.VarChar);
        parClosedUser.Value = IssueClosedByddl.SelectedValue;
        OleDbParameter parClosedDate = cmd.Parameters.Add("@ClosedDate", SqlDbType.VarChar);
        parClosedDate.Value = ClosedDatetxt.Value;

       //=======
    
        cmd.ExecuteNonQuery();
        
        con.Close();

    }