get multiple row value

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

  • Posted 8 September 2017, 1:45 pm EST

    <p>I have added multiple row in spreadsheet  using button click event but can't collect value from those added row.</p><p>please send some sample code how can i add multiple row in spread sheet and insert data in database</p><p> </p><p>Thanks</p><p> </p><p>Azad </p>
  • Replied 8 September 2017, 1:45 pm EST

    <p>Hello Azad, </p><p>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:</p><blockquote><p><code class="VB"><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><br><font class="keyword">Dim</font> sqlStr
    <font class="keyword">As</font> <font class="keyword">String</font> = <font class="string">"SELECT * FROM Patients"</font><br><font class="keyword">Dim</font>
    conn <font class="keyword">As</font> <font class="keyword">New</font>
    System.Data.OleDb.OleDbConnection(conStr)<br><font class="keyword">Dim</font> ds
    <font class="keyword">As</font> DataSet = <font class="keyword">New</font>
    DataSet()<br><font class="keyword">Dim</font> da <font class="keyword">As</font>
    <font class="keyword">New</font> System.Data.OleDb.OleDbDataAdapter(sqlStr,
    conn)<br>FpSpread1.ActiveSheet.DataAutoHeadings = <font class="keyword">False</font><br>FpSpread1.ActiveSheet.DataMember = <font class="string">"Patients"</font><br>da.Fill(ds)<br>FpSpread1.ActiveSheet.DataSource
    = ds<br>    FpSpread1.ActiveSheet.AddUnboundRows(1,
    2)<br>    FpSpread1.ActiveSheet.SetValue(2, 0, <font class="string">"Daly"</font>)<br>    FpSpread1.ActiveSheet.SetValue(2, 1, <font class="string">"John"</font>)<br>    FpSpread1.ActiveSheet.SetValue(2, 2, <font class="string">"111390"</font>)<br>    FpSpread1.ActiveSheet.SetValue(2, 3, <font class="string">"12 Courtney
    Place"</font>)<br>    FpSpread1.ActiveSheet.AddRowToDataSource(2, <font class="keyword">True</font>)<br><font class="keyword">End</font> <font class="keyword">If</font></code> </p></blockquote><p>The example uses the Patients.mdb database which gets installed with the Spread control. Hope this hepls.</p><p>Thanks, </p><p>Suresh</p>
  • Replied 8 September 2017, 1:45 pm EST

    <p>Hello SureshD </p><p> </p><p>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.</p><p> </p><p>Thanks</p><p> Azad </p>
  • Replied 8 September 2017, 1:45 pm EST

    <P>Azad,</P>
    <P>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.</P>
Need extra support?

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

Learn More

Forum Channels