Hi

I want to generate sequence number in C# window application I have got one link on Google, but I it is not helpful. I want that on click to add button an order sequence number should generate and stored in SQL Database

i have written this code but it is not helpful

{
                String file2 = "ordernumber.txt";
                 FileInfo firead = new FileInfo (file2);
                String Input = String.Empty;
                int Num =1;
                if(firead.Exists)
        {
            Input=File.ReadAllText(file2);
        }
            if(Input!=String.Empty)
        {
            Num=Convert.ToInt32(Input);
        }
            File.WriteAllText(file2,(Num+1).ToString());
            return;
        }

Please help me to generate sequence number in C# and stored in SQL Database

Hi

I want to generate sequence number in C# window application I have got one link on Google, but I it is not helpful. I want that on click to add button an order sequence number should generate and stored in SQL Database

i have written this code but it is not helpful

{
                String file2 = "ordernumber.txt";
                 FileInfo firead = new FileInfo (file2);
                String Input = String.Empty;
                int Num =1;
                if(firead.Exists)
        {
            Input=File.ReadAllText(file2);
        }
            if(Input!=String.Empty)
        {
            Num=Convert.ToInt32(Input);
        }
            File.WriteAllText(file2,(Num+1).ToString());
            return;
        }

Please help me to generate sequence number in C# and stored in SQL Database

Do you have any lines or data in the text file to generate sequence number accordingly to each line? explain exact what you are looking for..

con.Open();
            SqlDataAdapter da = new SqlDataAdapter("select * from RoomBooking",con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            DataTable dt = ds.Tables[0];

            int ctr, len;
            string codeval;
            len = dt.Rows.Count - 1;
            DataRow dr = dt.Rows[len];
            string code = dr["CusID"].ToString();
            codeval = code.Substring(1, 3);
            ctr = Convert.ToInt32(codeval);

            if ((ctr >= 1) && (ctr < 9))
            {
                ctr = ctr + 1;
                textBox1.Text = "C00" + ctr;
            }
            else if ((ctr >= 9) && (ctr < 99))
            {
                ctr++;
                textBox1.Text = "C0" + ctr;
            }
            else
            {
                ctr++;
                textBox1.Text = "C" + ctr;
            }
            con.Close();
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.