New topic: REALSQLDatabse - Need Help
<http://forums.realsoftware.com/viewtopic.php?t=44799> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message neu1886 Post subject: REALSQLDatabse - Need HelpPosted: Sat Jul 21, 2012 5:14 pm Joined: Sun Feb 19, 2012 4:15 pm Posts: 3 Hello, I just programming a family tree software. I've created a table structure. The database is based on REALSQLDatabase. I would not have duplicate entries in my tables (first name, family name). Each name record has a field for first name and one for the last name. If a person has several names, the name string is split. It shall now be examined for each name part, if this is already included in the table. If so, then its ID is passed to the array GivnIDs, otherwise these names will be added to part us then read his new ID and add to the array GivnIDs. The Given Name column of the table "Names" will be just a comma-separated string with the IDs of the first name of the person included. Unfortunately this is not the source. I can not find the error. Can someone please help me? Thank you and greetings from Germany! Sub Add(DB As REALSQLDatabase, Optional ErrorMessage As String) Dim GIVN() As String Dim GivnIDs() As Integer Dim SurnID, i As Integer Dim rsGIVN, rsSURN, rsGivnID As RecordSet GIVN = Split(Me.GIVN) 'überprüft, ob Vornamen bereits in der Vornamen-Tabelle enthalten sind For i = 0 To UBound(GIVN) rsGIVN = DB.SQLSelect("SELECT * FROM Givennames WHERE Givenname='" + GIVN(i) + "'") 'wenn Name gefunden, dann ID auslesen If rsGIVN <> Nil And Not rsGIVN.EOF Then GivnIDs(i+1) = rsGIVN.Field("GivennameID").IntegerValue Else 'sonst neuen Vornamen einfügen und ID auslesen Dim drGIVN As New DatabaseRecord drGIVN.Column("Givenname") = GIVN(i) If DB.Connect Then DB.InsertRecord("Givennames", drGIVN) DB.Commit GivnIDs(i+1) = DB.LastRowID Else MsgBox("No Database connection!") End If End If Next 'überprüft, ob Nachname bereits in der Nachnamen-Tabelle enthalten ist rsSURN = DB.SQLSelect("SELECT * FROM Surnames WHERE Surname='" + Me.SURN + "'") 'wenn Name gefunden, dann ID auslesen If rsSURN <> Nil And Not rsSURN.EOF Then SurnID = rsSURN.Field("SurnameID").IntegerValue Else 'sonst neuen Vornamen einfügen und ID auslesen Dim drSURN As New DatabaseRecord drSURN.Column("Surname") = Me.SURN If DB.Connect Then DB.InsertRecord("Surnames", drSURN) DB.Commit SurnID = DB.LastRowID Else MsgBox("No Database connection!") End If End If 'Name einfügen Dim Givenname As String Dim drName As New DatabaseRecord drName.IntegerColumn("SurnameID") = SurnID For i = 0 To UBound(GivnIDs) Givenname = Givenname + CStr(GivnIDs(i)) + " " Next drName.Column("Givenname") = Givenname If DB.Connect Then DB.InsertRecord("Names", drName) DB.Commit Else MsgBox("No Database connection!") End If End Sub So I insert a new person in the database: Sub Action() Dim Name As New GenXName Dim Person As New GenXPerson Name.GIVN = TextArea1.Text Name.SURN = TextField1.Text Person.PersonName = Name Person.Gender = PopupMenu1.ListIndex + 1 Person.Add(App.GenX.DB) End Sub Top timhare Post subject: Re: REALSQLDatabse - Need HelpPosted: Sat Jul 21, 2012 6:30 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 11537 Location: Portland, OR USA What is the error? Do you get an OutOfBoundsException? Do you get anything added to the database? Can you describe what it is doing that is different than what you expect it to do? Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ]
-- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
