ali raza

C#, .Net , and my thoughts

how to get oracle sequence numbers in .net

hi the main Query to get sequence number is follow

select JOB_ID_SEQ.NEXTVAL from dual;

i get the required Sequence number value form following method

public int GetOracleSequenceValue(string _SequenceValue)
OdbcCommand _command = new OdbcCommand();
int _ItemValue = -1;
OdbcConnection _con = new OdbcConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["RCConnectionString"].ToString());
_command.Connection = _con;
string _QueryString = "select "+ _SequenceValue +" from dual ";
_command.CommandText = _QueryString;
_ItemValue = Convert.ToInt32(_command.ExecuteScalar().ToString());
catch (Exception ex)
Util.LogErrorToFile(ex, "MYExecuteNonQuery", "error");
return _ItemValue;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: