-2

I am working on a button that will execute a stored procedure. When the data is returned I only needed the record number to be passed into an array which will later be used for the back page. The backpage for the aspx will then input the record number into a string and will redirect the user to the RecordInfo page. Here is what I have so far but I keep getting the same error:

{"An SqlParameter with ParameterName '@RecNum_OUT' is not contained by this SqlParameterCollection."}

I hope you can assist me.

 <asp:Button ID="GetNextRec" runat="server" Text="Get Part" 
             onclick="GetNextRec_Click" OnCommand="btnNext_OnClick" />

ASPX.CS

protected void GetNextRec_Click(object sender, EventArgs e)
{
        String[] q = new String[1];
        q = Record.GetNextRec();
        Response.Redirect("~/PartsRecord.aspx?mode=full&queue=" + q[0], false);
}

Database cs

  public static String[] GetNextRec()
    {
        Database db = DataFactory.CreateDatabase();
        DbCommand dbc = db.GetProc("GetNextRec");

        db.ExecuteNonQuery(dbc); // IDK if this si doing anything
        String[] q = new string[1];
        q[0] = dbc.Parameters["@RecNum_OUT"].Value.ToString(); // "An SqlParameter with ParameterName '@requisition_OUT' is not contained by this SqlParameterCollection."}
        return q;
    }
user1880670
  • 162
  • 2
  • 2
  • 10
  • `I want to just let the stored procedure gather the data needed and return the part info into the datagrid. `, what exactly does that mean? – Mike Perrenoud Apr 15 '13 at 18:43
  • What I meant to say is that the stored procedure has is already set to get the data that I would like to retieve. This data will then need to be inserted into the datagrid – user1880670 Apr 15 '13 at 18:47
  • What issue are you having? Are you getting an exception? – Daniel Mann Apr 15 '13 at 18:54
  • This is the error that pops up: Procedure GetNextRec has no parameters and arguments were supplied – user1880670 Apr 15 '13 at 18:57
  • I believe you are looking for something like this http://stackoverflow.com/questions/101033/how-to-return-multiple-rows-from-the-stored-procedure-oracle-pl-sql – Thiago Apr 15 '13 at 19:17

2 Answers2

0

Ok, so to call the procedure without the parameters just remove these two lines:

db.AddOutParameter(dbc, "Record_OUT", DbType.String, 15);
db.AddOutParameter(dbc, "locator_OUT", DbType.String, 9);
Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232
  • This wont help I tried so many ways. However, I have changed my approach and would like some help if your up to the challenge. – user1880670 Apr 15 '13 at 20:41
  • @user, what exactly did you change about your approach? Did you update the question with this new approach and the problems you're having? – Mike Perrenoud Apr 16 '13 at 09:08
0

So I finally, figured it out. I was able to populate the page I needed based on the parameter set within the stored procedure. I used the folloing code:

db.AddOutParameter(dbCommand, "RecNum_OUT", DbType.String, 15);--

below the command to get the procedure needed. Once I added that line everything worked fine.

Thanks to those who tried to help.

user1880670
  • 162
  • 2
  • 2
  • 10