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

     

    Thanks

     

    Azad 

  • 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:

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

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

    Thanks, 

    Suresh

  • 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.

     

    Thanks

     Azad 

  • Replied 8 September 2017, 1:45 pm EST

    Azad,


    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