Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

How to prevent storing duplicate values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dotpro2008 - 15 Feb 2008 00:17 GMT
In ASP.NET 2.0 project, I have added a  dataset and have setup the datatable
and configured the datatableadapter (using the wizards).

In my code I can use the mytableadapter.insert method to insert a new record
in the table.

How do I check if the key column value being inserted this time already
exists and hence prompt the user the message ("userid already exists" or
"email address already exists")

Thanks,
Misbah Arefin - 15 Feb 2008 22:05 GMT
You can use the DataTable.Select() method to search for the userid in the
datatable if it exists then show error message otherwise insert
another option would be to create a unique index on the userid column
DataTable.Columns["ColumnName"].Unique = true;

Signature

Misbah Arefin

> In ASP.NET 2.0 project, I have added a  dataset and have setup the datatable
> and configured the datatableadapter (using the wizards).
[quoted text clipped - 7 lines]
>
> Thanks,
Misbah Arefin - 15 Feb 2008 22:32 GMT
sorry to RE: on my own post but if your original intent was that the dattable
is empty and you are inserting a new row and wanted to check it against the
db rows then you would have to execute some SP which would seach the db table
for that value and return a scalar value indicating if the data exists or not

Signature

Misbah Arefin

> You can use the DataTable.Select() method to search for the userid in the
> datatable if it exists then show error message otherwise insert
[quoted text clipped - 12 lines]
> >
> > Thanks,

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.