hi,
i am developing a web application in asp.net, i need to generate UserId and Password for different users. so the UserId is should be in their designation(like EIDPRO-0025,EIDMM-0025,EIDTL-0026).The EIDPRO,EIDMM,EIDTL is different users, I need the Numeric value (0025,0026,0026) should be increment. how to do this? Anyone give me solution for this

You can store these values in a database table. When its time to create a new user, read the last value and use some type of formula to increment the value by 1. Do you have any code you are working with yet?

hello Mr.JorgeM i have no code for this, that's why i'm asking. can you help me?

Sorry, I thought you were asking for guidance. If you have partially working code that would be helpful.

I do not have any pre-built code to share with you. Maybe some other member would be willing to design it, develop this code up for you and just turn it over.

Hi raajsj,

I think what JorgeM is sugesting is that you have a go at coding it and let us know where you hit problems...

start by writing breaking down what you want to happen into a flow chart then for each stage of the flow chart try to write some code that will carry out the task.

Hi JorgeM,
I have a code but it is not working, that's why i said like that i have no code.
sorry, the thing is my database field name "Userid" datatype "varchar(50)". the User-id should be in "Empid-005" this format, so i used the datatype "varchar".
in my application i'm using classfiles, properties,storedprocedures and all.

Stored procedure query "Select userid from mytablename"

how can i read last userid?

how to split this 'Userid' field into "EMPID",001 ? 
i need only numeric value '001'.

this is my code:

     public string generateEmployeeid()
        {

            int id;
            int count = 001;
            string typ = "EMPID-";
            objDataBaseClass = new DataBaseClass();// db connection
            id = objDataBaseClass.GetDataTable("spGetEmployeeID");//storedprocedure name
            if (Table.Rows.Count != 0)
            {
                DataRow Row = Table.Rows[0];
                id = int.Parse(Row[0].ToString());
                returnString = typ + (count + id).ToString();
            }
        return returnString;

To split the string at the dash, with string str being the returned result ...

string s = str.Substring(str.IndexOf("-")+1, str.Length - (str.IndexOf("-")+1));
Hi ggamble,
thank u ggamble, i've ho idea for how can i read the 'last' UserId value means 

for example
This is the table content 
UserId    // this is the field name and Empid-005....010 is values
Empid-005
Empid-006
Empid-007
Empid-008
Empid-009
Empid-010

i need to read the last Userid (Empid-010) from this table.
the problem is field datatype 'varchar'...

how to do this? anyone give me the solution....

Is there an id field in the table? if so, your SP can do the below.

select *
from    TableName
where   Id = (select max(Id)  from TableName)

Thank u.., ggamble..

thanks to all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.