-
I can only tell you one idea, first of all, see if your database table has an index or primary key, if so, select a number of fields by pressing the primary key or index, and compare them with the corresponding fields of the information you want to add.
When fetching data, use the distinct clause to perform a unique filter.
To be precise, if your database table itself has unique indexes, it is impossible to insert data repeatedly.
-
What I did a long time ago was to set that field to'key'If it is a duplicate, the database engine will send back a wrong code, and then tell the user.
I never had a chance to write a database program again, and now I forgot about it :(
-
First, you might start by inserting the smallest unit used in the database field query, such as your minimum unit x16
Then, use the query statement "select count(*)from [table name] to locate like x16" as the verdict, and the result is that it is not = 0 and cannot be repeated.
The second problem is that as long as the program records the user's actions, it basically establishes a record table in the database, and then sends a description of the recorded operation content in the log table at all times more than each data operation, so that all database operations can be logged.
-
First of all, you can query the smallest unit of the "location" field to be inserted into the database, for example, your minimum unit is x16
Then use the query statement select count(*)from [table name] to position like"%x16%"Just determine whether the result is = 0 or not, and you can know if there is a duplicate.
The second problem is that the program that records user operations basically creates a log table in the database, and then sends an additional record explaining the operation content to the log table every time a data operation is performed, so that all database operations are recorded.
-
if = "" or = "" then
msgbox ("Name and ID number are not allowed to be empty! ")
exit sub
end if
if flag = 0 then
if = adstateopen then 'Determines the status of the recordset, and closes it if it is open.
sql = "select * from jxgl where ID number ='" + "' "
sql, con, adopenstatic, adlockoptimistic 'Open the recordset.
if not then
msgbox ("ID number from the recovery! ")
exit sub
end if
This is the judgment before saving the data. The first is that the ID card is a null value and is not allowed to be saved. ID cards are not allowed to be saved.
If these two conditions are passed. will be saved.
-
I won't talk about connecting to the database.
The idea is that you check the database to see if there is a number you want to judge, for example: 0001
select * from table where id='0001'",conn,3,3
Look at how many records RS has.
If you don't know.
if and then
msgbox "0001 already exists"
end if
select * from table where id='0002'",conn,3,3
if and then
msgbox "0002 already exists"
end if
-
If there are no specific requirements for a student number, it can be set to an automatic number.
You can use the error number to tell that it's more convenient.
-
You can indicate in the form load event that there are several text boxes, all of which are displayed as null values at the same time, and there are no duplicates.
-
text should not be bound to adodc1, like this:
private sub command1_click()= "select * from where number='" & "'"
if > 0 then
msgbox "Records already exist"
elsemsgbox "The record does not exist"
Number") = Other fields")=
end if
end sub
private sub form_load()'There's no need for addnew here.
end sub
-
In VB, the database is queried with data that may have duplicate values, and if the data is queried, there are duplicate values.
The problem here is a bit unclear, if you don't know how to execute SQL query data under VB, it will be too much.
-
I did it with the following **, I don't know if there is a better way to dim sql as string
dim rs as new
sql= "select * from m_data where m_name like '"& Name variable to add &"'"
sql, conn, adopenkeyset, adlockpessimistic
if rs_recordcount > 0 thenmsgbox "It's already there! ", 48, "starsystem"
else would be fine.
end if
-
select dist (some fields have the same field name, only one), fields from table name order by field name group by field name (the field in dist).
-
For example, a table of student information: student number, name, gender, age.
The beginning has been added.
Now to implement the Add Duplicate a prompt that has been added.
Abnormal prompts. It's not ideal. Follow-up: Yes, I guess that's what you said.
select * from the table of student information where student number = the student number that was just newly entered'
Then judge the dataset that is interpolated by this SQL statement.
Determine if the count is 0. Proof that there was no previous student number. If it is not equal to 0.
It's just that I've had this student number before. Fidel's testimonial: 2009-05-18 Other (1) Zero Q coin 10 level 2009-05-18 I didn't use vb to implement, but in other languages is implemented in this way, in the database design number as the main key, then it can only be unique, there is no way to insert the same, then when inserting, an exception will be thrown, get this exception in **, and then prompt to repeat!
Hope it helps!
-
I'm dizzy!
rs, you didn't even assign a value to make a judgment??
-
Upstairs is right! The method of setting the primary key is even better! In addition to setting a field as a primary key, you can also set other related fields to have a distinct index. This ensures that the data is not duplicated!
-
In Access, you can set the field as the primary key or no duplicate indexes.
Personally, I think that the functions that can be achieved by setting up the database can be set as directly as possible.
Taking the win10 system as an example, the detailed steps to add a domain name to the compatibility site list are as follows: >>>More
Use the tool to program the task first, and then use the tool to write the task into the archive! I forgot what the software is called, you can check it.
When changes to data affect the index, the information in the index can be spread out across the database. Reindexing reorganizes the storage of indexed data (and in the case of clustered indexes, table data) and defragments it. This improves disk performance by reducing the number of page reads required to obtain the requested data. >>>More
MySQL exports the specified data table and data [command].
Attach a database or import a database.
SQL itself has data import operations. However, if you want to import data from a backup file, you need to do something else. Let's take an example. >>>More