Farpoint Web Spread 6

Posted by: jagan1982 on 8 September 2017, 2:56 pm EST

  • Posted 8 September 2017, 2:56 pm EST

    Hi,

       I am using Farpoint Web Spread 6. I am facing issuue on Edit/Update the data to database. I am using SQLdatasource of store procedures for select & update with parmaeters specified.In total there are 22 columns, and only 3 columns is editable.

       The error, I am getting is " Procedure or function xxx has too many arguments specified." When I am executing the sp alsone for update, it is sucessfully updating. where as I am getting the error only in application.

       Please advise me, to solve the issue.It's very urgent, as I am breaking my heads for a while.

      Thanks,

    Jagan

  • Replied 8 September 2017, 2:56 pm EST

    Paul,

       Where I need to use the error comand. Do I need paste the below code in my application? Please advise.

    private void FpSpread1ErrorCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e) 
    {
    if (e.CommandName == "InsertFailed")
    {
    TextBox1.Text = "Insert of row failed.";
    }
    }
     
    Also, What I understand from the error message is  - the application shows 20 fields, but I am editing 3 fields and also the store procedure accept only 3 parameters. How can I limit, the remaing 17 fields. Is there any properties available?
    Thanks,
    Jagan
  • Replied 8 September 2017, 2:56 pm EST

    This is the Spread for Winforms forum but I just noticed your title says FarPoint Web Spread 6. If this is indeed Spread for ASP.Net there is an ErrorCommand Event you can catch that would give us more information about what is failing in your Update. Please try this and let us know about your Event Data.

    ErrorCommand Event

    Occurs when the use of a command button causes an error.

    Syntax









    Visual Basic (Declaration)
    Public Event ErrorCommand As SpreadCommandEventHandler








    Visual Basic (Usage)Copy Code
    Dim instance As FpSpread
    Dim handler As SpreadCommandEventHandler

    AddHandler instance.ErrorCommand, handler








    C#
    public event SpreadCommandEventHandler ErrorCommand

    Event
    Data


    The event handler receives an argument of type SpreadCommandEventArgs
    containing data related to this event. The following
    SpreadCommandEventArgs properties provide information specific to this
    event.

























    PropertyDescription
    CommandArgument (Inherited from System.Web.UI.WebControls.CommandEventArgs)Gets the argument for the command.
    CommandName (Inherited from System.Web.UI.WebControls.CommandEventArgs)Gets the name of the command.
    EditValues
    Gets the postback data in an array list of
    values.
    Handled
    Gets or sets whether the event has been
    handled.
    SheetView
    Gets the sheet being updated.
    SortFrozenRows
    Gets or sets whether to the frozen rows should be
    sorted when sorting command happens.

    Remarks


    The ErrorCommand command name can be one of the following values:


















    ErrorDescription
    InvalidInputInput values are not valid
    UpdateFailedSpread failed to update the data model
    InsertFailedFarPoint could not insert the new row to the data model
    DeleteFailedFarPoint could not delete the specified row.

    The ErrorCommand command argument is the index of the row being
    acted on.


    The SpreadCommandEventHandler
    receives an argument of type SpreadCommandEventArgs
    containing data related to this event.


    Example

    This example
    illustrates the use of the event.







    C#Copy Code
    private void FpSpread1ErrorCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e) 
    {
    if (e.CommandName == "InsertFailed")
    {
    TextBox1.Text = "Insert of row failed.";
    }
    }








    Visual BasicCopy Code
    Private Sub FpSpread1ErrorCommand(ByVal sender As System.Object, ByVal e As FarPoint.Web.Spread.SpreadCommandEventArgs) Handles
    FpSpread1.ErrorCommand
    If e.CommandName = "InsertFailed" Then
    TextBox1.Text = "Insert of row failed."
    End If
    End Sub

    Requirements


    Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium
    Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows
    Server 2003 family, Windows Vista, Windows Server 2008 family

  • Replied 8 September 2017, 2:56 pm EST

    Paul,

        To make clear, I am displaying data through select store procedure and for update, I am using update store procedure. Out of 22 columns, only 3 columns are editable. I also specified the key columns for the property DataKeynames. Is anything else, do I need to mention in my code?

    Thanks,

    Jagan 

  • Replied 8 September 2017, 2:56 pm EST

    Paul,

       It's the store procedure, I am calling for the update.XXX is my procdure name.

  • Replied 8 September 2017, 2:56 pm EST

    Could you clarify what Procedure or function "xxx" is? What its definition says the arguments should be and what you are sending it in your code?
  • Replied 8 September 2017, 2:56 pm EST

    The best way I've found to add events so that they are wired up correctly is to go into the Design screen of the aspx page where Spread is and select the Spread and right click it then select properties. On the properties tab select events then scroll down to ErrorCommand and double click next to it. this will create an event stub on your aspx.cs or aspx.vb page and wire the event up for you. What you put inside the stub isn't that important, you can put a breakpoint in the first "{" inside it and do a quickwatch on the event args to get the information we are interested in.
  • Replied 8 September 2017, 2:56 pm EST

    You may need to catch the UpdateCommand Event. It fires once for each row you have edited. The Event Data includes CommandArgument which should be the row it is being fired for, the CommandName, and the EditValues which is an arraylist of the postback data. You could probably find the 3 fields you need from that and call your Stored Procedure giving it those 3 arguments. The UpdateCommand is another event of the FpSpread Class and you can find its information in the documentation
  • Replied 8 September 2017, 2:56 pm EST

    One of our developers has suggested you could try this code. You would need to add the Update Event and put this code into it and add the dataSourceCallback method



    protected void FpSpread1_UpdateCommand1(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs
    e)

           
    {

               
    int row = (int)
    e.CommandArgument;

     

               
    DataSourceView dsv = ((IDataSource) this.SqlDataSource1).GetView(string.Empty);

     

               
    IDictionary tmp = new
    Hashtable();

      
             IDictionary
    vals = new Hashtable();

               
    IDictionary olds = null;

               
    IDictionary keys = null;

     

               
    Hashtable dataKey =
    e.SheetView.GetDataKey(row) as Hashtable;

     

               
    keys = dataKey["key"] as IDictionary;

              
     olds = dataKey["value"] as IDictionary;

     

               
    for (int c = 0;
    c < e.SheetView.ColumnCount; c++)

               
    {

                   
    if (!e.SheetView.Columns[ c].Locked)

                   
    {

                       
    string cname = e.SheetView.GetColumnLabel(0,
    c); // use data column name.

                       
    if (cname != null)

                       
    {

                           
    if (olds != null
    && olds.Contains(cname))

                           
    {

                               
    tmp.Add(cname, olds[cname]);

                               
    vals.Add(cname, olds[cname]);

                           
    }

                           
    object val = e.EditValues[ c]; // convert value if needed.

                           
    if (val!=FpSpread.Unchanged)
    vals[cname] = val;

                       
    }

                   
    }

               
    }

               
    // the vals and tmp should only contains the values
    for the columns in the UpdateParameters.

               
    dsv.Update(keys, vals, tmp, new DataSourceViewOperationCallback(dataSourceCallback));

     

               
    e.Handled = true;

           
    }

     

           
    private bool
    dataSourceCallback(int rows, Exception e)

           
    {

               
    // if (e!=null) failed;

               
    return true;

           
    }



  • Replied 8 September 2017, 2:56 pm EST

    You said earlier that your Stored Procedure only took 3 arguments but the markup you just posted has 7 Update parameters listed

    Did you create this or was it created for you from some settings you made in Design view through the SqlDataSource component? Have you tried commenting out the parameters you don't need here?

  • Replied 8 September 2017, 2:56 pm EST

    Paul,

       Sorry, It's 7 parameters only.Is anything else, do i need to specify in order to update.

    I mean any code, do i need to write in code-behind file. I tried the same store procedure with Visual studio grid, and the data is updated in DB. I am facing the issue only web spread.

    Please advise.

    Thanks,

    Jagan

  • Replied 8 September 2017, 2:56 pm EST

    Paul,

       I am already passing the parameters via SQL data source, below is the code i am using in .aspx page and I am passing the field "AccountNo" as Datakeynames property. In total there are 7 parameters for the update store procedure.

      Through SELECT store procedure, there are 22 fields.

      

    ConnectionString="Data Source=z3msdw05;Initial Catalog=ODS;User ID=usr_WriteBack;Password=usr_WriteBack;Connect Timeout=100;Load Balance Timeout=100"

    SelectCommand ="sp_GetAssetFinanceProvisionReport" SelectCommandType="StoredProcedure" updateCommand="sp_UpdateAFProvision" UpdateCommandType="StoredProcedure"

    ProviderName="System.Data.SqlClient" onselecting="AFDataSource_Selecting" >

    Thanks,
    Jagan

  • Replied 8 September 2017, 2:56 pm EST

    Paul,

       Thanks for your code. Do I need to modify the code or I can simply copy/paste the code.

       However, I can change SQLdata source name. Other than, in the code any where do I need to change anything? Please advise.

     Thanks,

    Jagan

  • Replied 8 September 2017, 2:56 pm EST

    Hello Jagan,

    Please elaborate a bit more on your requirement. I don't think your formula is working. Your code is applying the formula to the whole column. Please let me know what formula you want to apply to a cell/column.

     

    Thanks,

  • Replied 8 September 2017, 2:56 pm EST

    Paul,

        Thanks for your reply, I atlast found the solution. The farpoint web spread expects the parameter sequence in the same order as in store procedure.Normally, other grids won't make this difference.

        Now, I am facing another issue. The issue is on getting update on total in client side. i.e. when I change the value in cell, it should reflect the total sum in the footer.

        I made the below change, but the total sum is not changing in client side. Can you please adive, what's wrong on below code

    ---- in aspx file 

    ClientAutoCalculation= "true"

    ----- in Code behind file

     protected void Page_Load(object sender, EventArgs e)
            {
               //FpSpread1.Sheets[0].ColumnFooter.Columns[5].Formula = "SUM(F)";              
        
            }

    thanks,

    Jagan

     

  • Replied 8 September 2017, 2:56 pm EST

    I don't really know anything about your DataSource it would be hard for me to determine if any modifications need to be made without having access to it. Simply copy and pasting the code into yur application would not work because the event would not be wired up. I would suggest you add the event through the FpSpread Properties pane Events Tab as described above then paste the code inside the event. You can debug from there to determine if it is working or not.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels