Add a new table/row programmatically


Author
Message
Gerhard Jaros
Gerhard Jaros
StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)
Group: Forum Members
Posts: 18, Visits: 22
I've a dataset and want to add this data to an existing BusinessObject. The fields of the business object are exactly the same than those of my data table. How can I automatically add this data? BO.NewRow() just adds an empty row and also BO.Add()

...gerhard...

Replies
Gerhard Jaros
Gerhard Jaros
StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)StrataFrame Beginner (24 reputation)
Group: Forum Members
Posts: 18, Visits: 22
Do you maybe have an answer to my question? I meanwhile tried all kinds of different delete events and they also do not set the isDirty prop to true.

Thank you very much!

...gerhard...

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I don't know what you are trying to accomplish.  The Clear removes any of the data within the BO and resets any flags.  Calling a Clear() and then a Save() would do literally nothing.  What are you trying to accomplish?

Just so you can better understand this, run this code:

MyBO.Clear()

MsgBox(MyBO.Count.ToString())

You will get a message box with a "0" in it.  There are no records in the BO after you call a clear...the records are not deleted, the BO is just cleared of its data.  If you want to delete all of the records in the BO, the easiest thing to do is enumerate and get all of the PKs then delete all of the PKs at once:

Dim loPKs As New System.Collections.Generics.List(Of Integer)

If MyBO.MoveFirst()
    Do
         loPKs.Add(MyBO.MyPrimaryKey)
    Loop While MyBO.MoveNext()
End If

'-- Now delete the records
For Each lnPK As Integer IN laPKs.ToArray()
    MyBO.DeleteByPrimaryKey(lnPK)
Next

You don't need to call the save because the DeleteByPrimaryKey immediately deletes the record on the server.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Gerhard Jaros - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Gerhard Jaros - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Gerhard Jaros - 19 Years Ago
                     Sorry, it doesn't append 11 empty rows, it appends nothing....
Gerhard Jaros - 19 Years Ago
                         Do you have the same structure in the data table that is populated...
Trent L. Taylor - 19 Years Ago
                             The structure is exactly the same
Gerhard Jaros - 19 Years Ago
                                 There are two things which could maybe help me: 1. Where can I find...
Gerhard Jaros - 19 Years Ago
                                 There is not a lot of rocket-science in this method :D If you debug...
Trent L. Taylor - 19 Years Ago
                                     [quote]Where can I find the source code of CopyDataFrom() in the...
Trent L. Taylor - 19 Years Ago
                                     :) this.CurrentDataTable is empty before I run CopyDataFrom and it...
Gerhard Jaros - 19 Years Ago
                                         Then you need to either put a debug on your data connection in the...
Trent L. Taylor - 19 Years Ago
                                             [quote][b]Trent L. Taylor (10/30/2006)[/b][hr]Then you need to either...
Gerhard Jaros - 19 Years Ago
                                                 [quote]mydebug.html is empty.[/quote] Not possible if you have the...
Trent L. Taylor - 19 Years Ago
                                                     Nobody on this world can ever say that you're not patient :) I did...
Gerhard Jaros - 19 Years Ago
                                                         This looks OK....did you try to Save() your changes with this code in...
Trent L. Taylor - 19 Years Ago
                                                             Yes, I use this lines of code since I work on this project and I'm...
Gerhard Jaros - 19 Years Ago
                                                                 This would explain all of your other problems. Do you have anything in...
Trent L. Taylor - 19 Years Ago
                                                                     There is nothing in my DataSourceKey property, and if I insert data...
Gerhard Jaros - 19 Years Ago
                                                                         I bet your BO is not dirty when you are copying over the data. Look at...
Trent L. Taylor - 19 Years Ago
                                                                             [quote][b]Trent L. Taylor (10/30/2006)[/b][hr]I bet your BO is not...
Gerhard Jaros - 19 Years Ago
                                                                                 Do you maybe have an answer to my question? I meanwhile tried all...
Gerhard Jaros - 19 Years Ago
                                                                                     I don't know what you are trying to accomplish. The Clear removes any...
Trent L. Taylor - 19 Years Ago
                                     :) this.CurrentDataTable is empty before I run CopyDataTable() and it...
Gerhard Jaros - 19 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search