No stop on DatabaseException

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 + “’)”

Catch error As DatabaseException
mm= error.Message
End Try

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.

so is no way to skip that type of error.


one other suggestion… PREPARED STATEMENTS :slight_smile:

Hi Dave
what is the deference on using PREPARE STATEMENTS

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


[quote=479998:@Alexis Colon Lugo]Ok
so is no way to skip that type of error.

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?

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

Xojo version ?

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

I found the Problem now i have to works with this

for each row as DatabaseRow in Rs


For Each PhoneNum As String In PhoneNumStr


If you’re using API 2 database calls, you won’t need to worry about prepared statements (usually). It’s all handled internally.