Reputation: 131
Hi I am new to Sqlite Database environment. I created a table with few fields and make 2 fields as UNIQUE. So, I have to show an alert to user while he/she inserts the duplicate data into table. Can anyone tell me "How to check for an existing data before it can be inserted into the table in sqlite database"
Upvotes: 1
Views: 1230
Reputation: 4561
You have to query the input data entered by user and check whether it is present or not,
like fire the query select count() from category where categoryName='usertext'
obviously you know where to check the data
that is name of table(category
in my case i.e. in above query) and column name(categoryName
).
If count is more than zero,data is exist,you can alert user
else not exist.
Upvotes: 2