How to prevent storing duplicate values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?ZG90cHJvMjAwOA==?=

    How to prevent storing duplicate values

    In ASP.NET 2.0 project, I have added a dataset and have setup the datatable
    and configured the datatableadapte r (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,



  • =?Utf-8?B?TWlzYmFoIEFyZWZpbg==?=

    #2
    RE: How to prevent storing duplicate values

    You can use the DataTable.Selec t() 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.Colum ns["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 datatableadapte r (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,
    >
    >
    >

    Comment

    • =?Utf-8?B?TWlzYmFoIEFyZWZpbg==?=

      #3
      RE: How to prevent storing duplicate values

      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.Selec t() 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.Colum ns["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 datatableadapte r (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,

      Comment

      Working...