cmd = new SqlCommand(str, GFun);
in this line use your sql connection instead of global connection.. because the error you are getting popup when you are not entering the accurate no of parameters or datatype of those parameters of any method.
Further its very simple if you want to make an increment in your COMPANY ID in each click...
Just create a method in which you have a sql query of getting MAX value from the company_id column and save that value in any int variable by converting it into int. then create an increment in that int variable.
like:
public string getMaxID()
{
try
{
OracleCommand cmd = new OracleCommand("select nvl(max(company_id)+1,1) from table", dbConn);
dbConn.Open();
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
return dr[0].ToString();
}
catch (OracleException)
{
return "";
}
finally
{
if (dbConn.State == ConnectionState.Open)
{
dbConn.Close();
}
}
}
int company_id;
protected void btnnew_Click(object sender, EventArgs e)
{
company_id = Convert.ToInt32(getMaxID());
company_id++;
ddlCompanyid.SelectedItem.Text = "C000" + company_id.ToString();
}