Prevent entering data into DB twice

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.
 
A

ASP.Confused

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.
 
A

ASP.Confused

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.
 
A

ASP.Confused

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top