2 Replies - 634 Views - Last Post: 12 February 2017 - 02:05 AM

#1 karengsh  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 132
  • Joined: 18-May 09

Why is my update not working ? Help!

Posted 11 February 2017 - 09:56 PM

Hi,

I have been spending on this update for more than 2 weeks! and I can't get around the problem. Can someone help me out?

The updateMethod has three parameter UpdateRequest(string action, FormNo, name, status) like this :

internal void UpdateRequest(string action, string FormNo, string name, status)
 {
                eDAO.UpdateRequest(action, FormNo, name, status)
}       



and then on the form.cs I have a private updateRequest Method like this :

private void UpdateRequest(string action, string FormNo, Session["IssuerName"].ToString(), status)
{ 
                eBiz.UpdateRequest(action, FormNo, name, status);




internal void UpdateEPMTRequest2(string action, string FormNumber, string name, int status)
        {
            
            SqlCommand cmd = new SqlCommand("UpdateRequest", con);            
           
            cmd.Parameters.AddWithValue("@action", action);
            cmd.Parameters.AddWithValue("@FormNumber", FormNumber);
            cmd.Parameters.AddWithValue("@name", name);
            cmd.Parameters.AddWithValue("@status", status);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.ExecuteNonQuery();
            con.Close();
        }


My stored Procedure :
@action varchar(20),
	@FormNumber varchar(20),
	@name varchar(100),		
	@status int

if @action='Save' or @action='Submit'
begin

Insert into MASTER_REQUEST
([FormID],[IssuerName],[status]) Values ( @FormNumber, @name, @status)



Calling in the event :

protected void btnSave_Click(object sender, EventArgs e)
        {
            int status = 0;
            string Action = "Save";
            string name = "";
                if (status == 0)
                if (FormNumber != null)
                {
                    Session["FormID"] = FormNumber.ToString();
                    UpdateEPMTRequest2(Action, FormNumber, name, status);
                                          
                }
                        Response.Redirect("abc.aspx");
                    }
                



The FormNumber was declared right at the top at the page Load

FormNumber = generateRefNo();
Session["FormID"] = FormNumber.ToString();



Hope someone can help me out cos my boss said want to fail me....

Is This A Good Question/Topic? 0
  • +

Replies To: Why is my update not working ? Help!

#2 maceysoftware  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 350
  • View blog
  • Posts: 1,503
  • Joined: 07-September 13

Re: Why is my update not working ? Help!

Posted 11 February 2017 - 10:25 PM

Whats not working? Simply saying it doesn't work doesn't really help anyone. Do you have a SQL exception returned from your command? are you not getting that far? I can't see where your connection is being opened?
Was This Post Helpful? 0
  • +
  • -

#3 karengsh  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 132
  • Joined: 18-May 09

Re: Why is my update not working ? Help!

Posted 12 February 2017 - 02:05 AM

View Postmaceysoftware, on 11 February 2017 - 10:25 PM, said:

Whats not working? Simply saying it doesn't work doesn't really help anyone. Do you have a SQL exception returned from your command? are you not getting that far? I can't see where your connection is being opened?



I have left out the connection portion cos that part is working perfectly alright cos the other day I managed to inserted a hardcoded data.

There is no exception and error except that the data is not being inserted into the database.

I was thinking very hard just now.

Could it be that I have to do a bindtable staff like putting the string = the label.text etc and tied to the table so that data can then enter in ?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1