get multiple row value

Posted by: azad-aiub on 8 September 2017, 1:45 pm EST

  • Posted 8 September 2017, 1:45 pm EST

    I have added multiple row in spreadsheet  using button click event but can't collect value from those added row.

    please send some sample code how can i add multiple row in spread sheet and insert data in database





  • Replied 8 September 2017, 1:45 pm EST

    Hello Azad,

    In case you wishes to add rows with the data in the Spread control and then saving that data in your underlying dataset, then you may try using the AddUnboundRows and AddRowToDataSource methods of the control. An illustration of the same is also given in the help file of the control. The below mentioned code snippet will add 2 rows with data in the spread and database as well:


    <font class="keyword">Dim</font> conStr <font class="keyword">As</font> <font class="keyword">String</font> = <font class="string">"Provider=Microsoft.JET.OLEDB.4.0;data source= "</font> &
    Application.StartupPath & <font class="string">"\Patients2000.mdb"</font>
    <font class="keyword">Dim</font> sqlStr
    <font class="keyword">As</font> <font class="keyword">String</font> = <font class="string">"SELECT * FROM Patients"</font>
    <font class="keyword">Dim</font>
    conn <font class="keyword">As</font> <font class="keyword">New</font>
    <font class="keyword">Dim</font> ds
    <font class="keyword">As</font> DataSet = <font class="keyword">New</font>
    <font class="keyword">Dim</font> da <font class="keyword">As</font>
    <font class="keyword">New</font> System.Data.OleDb.OleDbDataAdapter(sqlStr,
    FpSpread1.ActiveSheet.DataAutoHeadings = <font class="keyword">False</font>
    FpSpread1.ActiveSheet.DataMember = <font class="string">"Patients"</font>
    = ds
        FpSpread1.ActiveSheet.SetValue(2, 0, <font class="string">"Daly"</font>)
        FpSpread1.ActiveSheet.SetValue(2, 1, <font class="string">"John"</font>)
        FpSpread1.ActiveSheet.SetValue(2, 2, <font class="string">"111390"</font>)
        FpSpread1.ActiveSheet.SetValue(2, 3, <font class="string">"12 Courtney
        FpSpread1.ActiveSheet.AddRowToDataSource(2, <font class="keyword">True</font>)
    <font class="keyword">End</font> <font class="keyword">If</font>


    The example uses the Patients.mdb database which gets installed with the Spread control. Hope this hepls.



  • Replied 8 September 2017, 1:45 pm EST

    Hello SureshD 


    I don't want this type of solution.I want user at first add multiple row then enter value like add row or insert.If any idea please write me.




  • Replied 8 September 2017, 1:45 pm EST


    The solution provided by Suresh is the way to implement this. You may need to break the code into different peices based on when you want it to happen. But the funcamentals are there to add unbound rows to the Spread (AddUnboundRows). Then, the user can type in these rows or you can programatically fill them or both. When you are ready to add these rows to the bound DataSource, you use the AddRowToDataSource method to add each row.

Need extra support?

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

Learn More

Forum Channels