How to increment the string value during run time without using dr.read() and store it in the oledb db?
<p>Here is my code, everything is working fine the only problem is with the ReadData() method in which i want the string value to be increment i.e AM0001,AM0002,AM0003 etc. This is happening till the execution of the program once i stop the execution of program, the second time when i run the program the same value i.e AM0001 is getting return. Due to this i am getting a error from oledb because of AM0001 is a primary key field.</p>

<p>enter code here:</p>

<p>class Jewellery : Connectionstr
    {</p>

<pre><code>    string lmcode;
    public string LM_code
    {
            get { return lmcode;}
            set { lmcode = ReadData();}
    }

    string mname;
    public string M_Name
    {
        get { return mname; }
        set { mname = value;}
    }

    string desc;
    public string Desc
    {
        get { return desc; }
        set { desc = value; }
    }


    public string ReadData()
    {
        string jid = string.Empty;
        string displayString = string.Empty;
        String query = "select max(LM_code)from Master_Accounts";
        Datamanager.RunExecuteReader(Constr,query);

          jid = LM_code;// this is working on first execution, the second time when i run the program the value null defined in LM_code.
          if (string.IsNullOrEmpty(jid))
            {
                jid = "AM0000";//This string value has to increment at every time, but it is getting increment only one time.
            }
            int len = jid.Length;
            string split = jid.Substring(2, len - 2);
            int num = Convert.ToInt32(split);
            num++;
            displayString = jid.Substring(0, 2) + num.ToString("0000");
            return displayString;
    }

    public void add()
    {


           String query ="insert into Master_Accounts values ('" + LM_code + "','" + M_Name + "','" + Desc + "')";
           Datamanager.RunExecuteNonQuery(Constr , query);
    }
</code></pre>

<p>Any help will be appreciated.</p>
