Database redundancy check

Last post 01-24-2008 5:30 AM by usmanbhatti531. 3 replies.

Sort Posts:

  • Database redundancy check

    01-21-2008, 3:05 PM
    • Member
      3 point Member
    • sesansoo
    • Member since 09-20-2007, 9:43 PM
    • Posts 9

    I am working on a small database program. I want to able to check recundancy when a new entry is entered. For example, if Check#1123 already in the database, i need to make sure the same number won't be entered into the same table. I am just a beginer on programing, so please help.

  • Re: Database redundancy check

    01-21-2008, 3:14 PM
    Answer
    • All-Star
      91,728 point All-Star
    • vinz
    • Member since 10-05-2007, 11:47 AM
    • Cebu, Philippines
    • Posts 13,769
    • TrustedFriends-MVPs

    Check this thread

    http://forums.asp.net/p/1207418/2122578.aspx#2122578 

    "Code,Beer and Music ~ my way of being a programmer"

  • Re: Database redundancy check

    01-24-2008, 4:36 AM
    Answer

    Hi, 

    Alternatively, you can change the "id" column to be a primary key in database, this will make the id is unique.

    To create or change a column to be PRIMARY KEY, you can see this:

    http://msdn2.microsoft.com/en-us/library/ms181043.aspx 

    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • Re: Database redundancy check

    01-24-2008, 5:30 AM
    Answer

       public bool CheckIDNO(string IDNO)
            {
                try
                {
                    bool NoExists = false;
                    Database db = DAC.GetDataDBConnection();
                    DbCommand dbCmd = db.GetStoredProcCommand("CheckNO", IDNO, NoExists);
                    db.ExecuteScalar(dbCmd);
                    NoExists = (bool)db.GetParameterValue(dbCmd, "Exists");
                    if (NoExists)
                        return true;
                    else
                        return false;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

     

    source for SP

    ALTER PROCEDURE [dbo].[CheckNO]

        @IDNO varchar(25),
        @Exists bit out
    AS
    BEGIN

        SET NOCOUNT ON;


        IF EXISTS(SELECT IDNO FROM Test WHERE IDNO = @IDNO )
        begin
            set @Exists= 1
        end
        else
            set @Exists= 0
    END


    I hope this will help you
     

    Muhammad Usman
    Please remember to click "Mark as Answer" on this post if it helped you.
    www.usman-bhatti.blogspot.com
Page 1 of 1 (4 items)