how to search for existing records before inserting

April 5, 2012 at 13:01:39
Specs: Windows XP
Looking for existing records vb.net

i want to search for an existing record before inserting a new one so i wont get double records so i can post a MsgBox saying that "record exists", i have a table named "CLIENT" and my column "Name"

by inserting i declared my code like this:
strsql = "insert into client(Name) values (@field1)"
objcmd = New MySql.Data.MySqlClient.MySqlCommand(strsql, objconn)

any suggestions would be appreciated


See More: how to search for existing records before inserting

Report •


#1
April 5, 2012 at 23:29:05
Normally you would set a unique primary key on your table so that the SQL engine would not allow duplicates. Alternatively, just do a SELECT first to see if it returns any records.

Report •

#2
April 6, 2012 at 17:15:01
Standard method was to first to search for item then to branch if found or not found.
Display or Create new.

Report •

Related Solutions


Ask Question