B
biteside
Hi,
I have a problem with inserting an record in Oracle. I am trying to
execute the following lines of code:
string query = "INSERT INTO USERS VALUES(USERS_SEQ.Nextval,'" +
Username + "','" + UserPassword + "','" + UserEmailaddress + "');" +
Environment.NewLine;
query += "SELECT max(USERID) from USERS;" + Environment.NewLine;
query += "COMMIT;";
OracleConnection con = new
OracleConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
OracleDataAdapter ad = new OracleDataAdapter();
ad.SelectCommand = new OracleCommand(query, con);
DataSet ds = new DataSet();
ad.Fill(ds);
return ds;
When I do the following error occurs:
System.Data.OracleClient.OracleException: ORA-00911
when I execute the result of this piece of code (the value in the
query variable) in Toad it works fine
INSERT INTO USERS VALUES(USERS_SEQ.Nextval,'test','test','test');
SELECT max(USERID) from USERS;
COMMIT;
I have tried to execute the code also without the
'Environment.NewLine' but then the result in the query variable won't
even execute in Toad.
Can anybody give any help on this matter? Or perhaps there is someone
out there who knows a better way to return the value of the last
inserted record in Oracle?
Thanks in advance.
B.
I have a problem with inserting an record in Oracle. I am trying to
execute the following lines of code:
string query = "INSERT INTO USERS VALUES(USERS_SEQ.Nextval,'" +
Username + "','" + UserPassword + "','" + UserEmailaddress + "');" +
Environment.NewLine;
query += "SELECT max(USERID) from USERS;" + Environment.NewLine;
query += "COMMIT;";
OracleConnection con = new
OracleConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
OracleDataAdapter ad = new OracleDataAdapter();
ad.SelectCommand = new OracleCommand(query, con);
DataSet ds = new DataSet();
ad.Fill(ds);
return ds;
When I do the following error occurs:
System.Data.OracleClient.OracleException: ORA-00911
when I execute the result of this piece of code (the value in the
query variable) in Toad it works fine
INSERT INTO USERS VALUES(USERS_SEQ.Nextval,'test','test','test');
SELECT max(USERID) from USERS;
COMMIT;
I have tried to execute the code also without the
'Environment.NewLine' but then the result in the query variable won't
even execute in Toad.
Can anybody give any help on this matter? Or perhaps there is someone
out there who knows a better way to return the value of the last
inserted record in Oracle?
Thanks in advance.
B.