Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to prevent storing duplicate values

Reply
Thread Tools

How to prevent storing duplicate values

 
 
dotpro2008
Guest
Posts: n/a
 
      02-15-2008
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,



 
Reply With Quote
 
 
 
 
Misbah Arefin
Guest
Posts: n/a
 
      02-15-2008
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;

--
Misbah Arefin



"dotpro2008" wrote:

> 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,
>
>
>

 
Reply With Quote
 
 
 
 
Misbah Arefin
Guest
Posts: n/a
 
      02-15-2008
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

--
Misbah Arefin



"Misbah Arefin" wrote:

> 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;
>
> --
> Misbah Arefin
>
>
>
> "dotpro2008" wrote:
>
> > 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,
> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Newbie - Need to prevent duplicate entries.. YMPN ASP .Net 3 01-14-2007 05:57 PM
Prevent duplicate entry to MS Access database mmazid@googlemail.com ASP .Net 0 02-08-2006 08:40 PM
How to prevent duplicate posting on a form w/ refresh? D. Shane Fowlkes ASP .Net 3 03-10-2005 09:05 PM
how to prevent duplicate objects in HashMap??? pembed2003 Java 4 04-04-2004 05:06 AM



Advertisments