No stop on DatabaseException

  1. 7 days ago

    Alexis C

    Mar 21 Pre-Release Testers, Xojo Pro Puerto Rico, USA

    This is my code how the app can continue with duplicate record
    SqlStr="INSERT INTO PhoneMSG(SocioName,SocioNum,MsgPhone) VALUES ('" + Rs.Column("SocioName").StringValue +"','" + Rs.Column("SocioNum").StringValue + "','" + PhoneNumStr + "')"

    Try
    DBConn.ExecuteSQL(SqlStr)
    Catch error As DatabaseException
    mm= error.Message
    End Try

  2. Dale A

    Mar 21 San Diego, California, USA

    What's the problem? Unless the table is set up to not allow them, databases can have duplicate records. So, assuming your SQL statement has no errors, the code you show should be fine.

    If your intent is to not allow duplicates, you either have to set up the column(s) as unique and specify the conflict resolution or try to retrieve the record from the database first and, if the record is not found, do the INSERT.

  3. Alexis C

    Mar 21 Pre-Release Testers, Xojo Pro Puerto Rico, USA

    Ok
    so is no way to skip that type of error.

    thanks

  4. Dave S

    Mar 21 San Diego, California USA

    one other suggestion.... PREPARED STATEMENTS :)

  5. Alexis C

    Mar 21 Pre-Release Testers, Xojo Pro Puerto Rico, USA

    Hi Dave
    what is the deference on using PREPARE STATEMENTS

  6. Dave S

    Mar 21 San Diego, California USA

    data safety .... pure and simple..... it does not reflect directly on your question, but was prompted by the query in your example.

    Without using Prepared Statements a malicious actor could use your own code against you, and inject or delete data

  7. Alexis C

    Mar 21 Pre-Release Testers, Xojo Pro Puerto Rico, USA

    ok
    thanks

  8. 6 days ago

    Dale A

    Mar 22 San Diego, California, USA

    @Alexis Cnbsp;Lugo Ok
    so is no way to skip that type of error.

    thanks

    I'm still not sure what you are trying to accomplish. Are you trying to prevent duplicate records? Or do you want them but the database won't permit it? What message is being returned in Error.Message?

  9. 4 days ago

    Alexis C

    Mar 24 Pre-Release Testers, Xojo Pro Puerto Rico, USA

    ok
    i have all working but this Rs.MoveToNextRow is no working on sqlite

  10. Emile S

    Mar 24 Europe (France, Strasbourg)

    Xojo version ?

  11. Norman P

    Mar 24 Pre-Release Testers, Xojo Pro outside drowning sorrows

    code .. sample code would go a long way to figuring out whats going on

  12. 3 days ago

    Alexis C

    Mar 25 Pre-Release Testers, Xojo Pro Puerto Rico, USA

    I found the Problem now i have to works with this

    for each row as DatabaseRow in Rs

    PhoneNumStr=Rs.Column("MsgPhone").StringValue.Split("|")

    For Each PhoneNum As String In PhoneNumStr
    TwilioMsg(PhoneNum)
    Next

    next
    thanks

or Sign Up to reply!