I am trying to update last number of sequence in database oracle using textbox on C#. When I tried to execute my program, I have got the error message {"ORA-01036: illegal variable name/number"} I am trying to rectify this problem, but I did not find how to fix it. I am new in #C and Oracle Database. Does anyone here could help me to solve this problem. Thank you in advance Here is my code
private void IDHEADER()
{
var result7 = new StringBuilder();
using (var connectio1n = new OracleConnection(@"Data Source=mcf;Persist Security Info=True;User ID=tmci38001;Password=tmci38001;"))
{
string CommandText2 = "SELECT LAST_NUMBER FROM USER_SEQUENCES WHERE SEQUENCE_NAME = 'TMCI_SEQ_BC_AJU_HEADER'";
OracleCommand command2 = new OracleCommand(CommandText2, connectio1n);
connectio1n.Open();
using (OracleDataReader dr = command2.ExecuteReader())
{
while (dr.Read())
{
String a = dr[0].ToString();
ID_HEADER.Text = a;
}
}
}
}
private void btnUpd_Click(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;
DialogResult result = MessageBox.Show("Update Sequence ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
if (string.IsNullOrEmpty(ID_HEADER.Text))
{
MessageBox.Show("Please Fill in all necessary fields",
"Incomplete Input", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
String HEADER = ID_HEADER.Text.Trim();
OracleConnection db = new OracleConnection("Data Source=mcf;Persist Security Info=True;User ID=tmci38001;Password=tmci38001;");
db.Open();
OracleCommand cmd8 = new OracleCommand("ALTER SEQUENCE TMCI_SEQ_BC_AJU_HEADER INCREMENT BY LPAD(TO_NUMBER(:HEADER),0); SELECT TMCI_SEQ_BC_AJU_HEADER.NEXTVAL FROM DUAL; ALTER SEQUENCE TMCI_SEQ_BC_AJU_HEADER INCREMENT BY 1 ", db);
cmd8.BindByName = true;
cmd8.Parameters.Add(":HEADER", HEADER);
OracleDataReader oraReader8 = null;
oraReader8 = cmd8.ExecuteReader();
oraReader8.Close();
db.Close();
db.Dispose();
IDHEADER();
Cursor = Cursors.Default;
MessageBox.Show("BC Sequence Successfully updated...");
}
}
}
As additional information, the error line thrown in oraReader8 = cmd8.ExecuteReader();