title: Two types of Users with one Login form - ASP.NET
body: <p>I'm working with ASP.NET Web applicaton and i'm completly lost with my project ! i have done so many methods but nothing has worked ! please i need someone to help me ! i have 2 types of tables (<code>Sellers</code> and <code>DevilryMen</code> ) now they are in tow separate tables (before they were in one table but everything went so wrong ! then i have decided to make it completely separate ) now i have finished the Registration page for both of them but my problem with the <code>Login</code> page ! i want to make one Login form for both but it didn't work ! could anyone please tell me if this is possible to make ? and how ? i know it's completely random question but i always end up delete everything and start again ! </p>
  
  <p>in case you need to look at my code : </p>
  
  <p>1- <code>First_Home.aspx:</code></p>
  
  <pre><code>&lt;form id="form2"&gt;
  &lt;asp:Login ID = "Login1" runat = "server" OnAuthenticate= "ValidateUser" UseSubmitBehavior="False" &gt;&lt;/asp:Login&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>2-  <code>First_Home.aspx.cs:</code>  i have done a login for <code>Sellers</code> only </p>
  
  <pre><code>   protected void ValidateUser(object sender, AuthenticateEventArgs e)
  {
      int userId = 0;
      string constr = ConfigurationManager.ConnectionStrings["MyDatabase"].ConnectionString;
      using (SqlConnection con = new SqlConnection(constr))
      {
          using (SqlCommand cmd = new SqlCommand("Seller_Validate_User"))
          {
              cmd.CommandType = CommandType.StoredProcedure;
              cmd.Parameters.AddWithValue("@Username", Login1.UserName);
              cmd.Parameters.AddWithValue("@Password", Login1.Password);
              cmd.Connection = con;
              con.Open();
              userId = Convert.ToInt32(cmd.ExecuteScalar());
              con.Close();
          }
          switch (userId)
          {
              case -1:
                  Login1.FailureText = "Username and/or password is incorrect.";
                  break;
              case -2:
                  Login1.FailureText = "Account has not been activated.";
                  break;
              default:
                  FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
                  break;
            }
       }
  }
  </code></pre>
  
  <p><strong>UPDATE :</strong> 
   Database Tables : </p>
  
  <pre><code>CREATE TABLE [dbo].[Users] (
      [Id]       INT           IDENTITY (1, 1) NOT NULL,
      [Username] NVARCHAR (50) NOT NULL,
      [Password] NVARCHAR (50) NOT NULL,
      [Email]    NVARCHAR (50) NOT NULL,
      [UserType] INT           NULL,
      PRIMARY KEY CLUSTERED ([Id] ASC),
      CONSTRAINT [AK_Users_Email] UNIQUE NONCLUSTERED ([Email] ASC),
      CONSTRAINT [AK_Users_Username] UNIQUE NONCLUSTERED ([Username] ASC)
  );    
  CREATE TABLE [dbo].[Sellers] (
          [Seller_ID]     INT           IDENTITY (1, 1) NOT NULL,
          [Name]          NVARCHAR (50) NOT NULL,
          [SUsername]     NVARCHAR (50) NOT NULL,
          [Password]      NVARCHAR (50) NOT NULL,
          [SEmail]        NVARCHAR (50) NOT NULL,
          [Phone]         NVARCHAR (50) NOT NULL,
          [City]          NVARCHAR (50) NOT NULL,
          [LastLoginDate] DATETIME      NULL,
          [CreatedDate]   DATETIME      NULL,
          PRIMARY KEY CLUSTERED ([Seller_ID] ASC),
      CONSTRAINT [FK_Sellers_Users_Username] FOREIGN KEY ([SUsername]) REFERENCES [Users]([Username]), 
      CONSTRAINT [FK_Sellers_Users_Email] FOREIGN KEY ([SEmail]) REFERENCES [Users]([Email]),
      );
      CREATE TABLE [dbo].[DeliveryMen] (
      [Delivery_ID]   INT             IDENTITY (1, 1) NOT NULL,
      [Name]          NVARCHAR (50)   NOT NULL,
      [DUsername]      NVARCHAR (50)   NOT NULL,
      [Password]      NVARCHAR (50)   NOT NULL,
      [DEmail]         NVARCHAR (50)   NOT NULL,
      [Phone]         NVARCHAR (50)   NOT NULL,
      [City]          NVARCHAR (50)   NOT NULL,
      [License]       VARBINARY (MAX) NOT NULL,
      PRIMARY KEY CLUSTERED ([Delivery_ID] ASC), 
      CONSTRAINT [FK_DeliveryMen_Users_Username] FOREIGN KEY ([DUsername]) REFERENCES [Users]([Username]), 
      CONSTRAINT [FK_DeliveryMen_Users_Email] FOREIGN KEY ([DEmail]) REFERENCES [Users]([Email]),
  </code></pre>