Prevent entering data into DB twice

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In the click event handler of an imagebutton (WebForm), my C# code gets the values in some textboxes and insert these values into database tables

The page reloads itself after this event and the text boxes are cleared

The user can then repeat the process

How can I prevent the user from inserting the original values in the textboxes more than once.
 
Lets say that there is a text box named tbx_name. You would use the
following string as your query string (in VB.NET):

Dim sql as string = "SELECT * FROM tblMyTable WHERE username='" +
tbx_name.Text + "'"

If the EOF flag is set, then the record doesn't exist.



In the click event handler of an imagebutton (WebForm), my C# code gets
the values in some textboxes and insert these values into database tables.
The page reloads itself after this event and the text boxes are cleared.

The user can then repeat the process.

How can I prevent the user from inserting the original values in the
textboxes more than once.
 
Or if you are using SQL, you can set fields to not have duplicates.


In the click event handler of an imagebutton (WebForm), my C# code gets
the values in some textboxes and insert these values into database tables.
The page reloads itself after this event and the text boxes are cleared.

The user can then repeat the process.

How can I prevent the user from inserting the original values in the
textboxes more than once.
 
NOTE: the way I described how to do the SQL string works with ADO, don't
know about ADO.NET, but I would think it would be the same.
 
Back
Top