0
if (tbsitename.Text != null)
        { 
            tbsitecode.Text = dm.GetData("select nvl(max(to_number(id)),0)+1 from setups_setup").ToString();
            //string code = dm.GetData("select lpad(nvl(max(to_number(code)),0)+1,2,0) from setups_setup where type = 'ISITE'").ToString();

            MessageBox.Show(dm.GetData("select max(id) from setups_setup").ToString());

            //int suc = dm.SetData("Insert into setups_setup(id) values (id)");

            //if (suc > 0)
            //{
            //    tbsitecode.Text = dm.GetData("select max(code) from setups_setup where type = 'ISITE'").ToString();

            //    MessageBox.Show("Record Saved.....");
            //}
        }

Dear ALL, I am new in this group as well as in c#/asp.net. I want to insert record in oracle, there is a primary key ID which I want to generate but the query isn't giving me new ID. If I am running this query in oracle it is working fine. any suggestion please...

1 Answers1

0
  1. I think sequence do it for you,
  2. This is sample how to insert with getting value from sequence
  3. Remember - use parameters instead pure query (SQL Injection)
Community
  • 1
  • 1