Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
pls help me for the auto generation of Emp id code in C#.net.
i am trying to write the code but the "throw new NOTIMPLEMENTEDEXCEPTION();" error is occuring again and again.
so pls help me to get out of it...
Posted
Comments
choudhary.sumit 6-Dec-12 1:55am    
what u mean by auto generation in c#.net.. explain in detail.
Anurag Sinha V 6-Dec-12 2:00am    
hi,
wat kinda code have u written?
post it..then we might be able to help u.. :)
Deenuji 6-Dec-12 2:01am    
Emp id is identity column...so u write this field in sql server database table...that generate the auto emp id!!!!!

1 solution

// SP
ALTER PROCEDURE dbo.GetRowsCount
AS
	SET NOCOUNT ON;
	
	SELECT * FROM users
	
	RETURN

// DAL
  public int getRowsCount()
        {
            con.Open();

            SqlCommand cmd = new SqlCommand("GetRowsCount", con);
            cmd.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);

            con.Close();

            return dt.Rows.Count;
        }

C#
//BAL
public int RowCount()
        {
            return usr.getRowsCount();
        }

C#
// while inserting data from UI
protected void btn_Click(object sender, EventArgs e)
       {

               bc.GetID = bc.RowCount() + 1;
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900