Oracle invalid character
-
I'm using c# and trying to access oracle here's my code:
try { String connString = "Provider=MSDAORA;Data Source=127.0.0.1;User id=system;Password=akar;"; string query = "insert into test values(" + textBox2.Text + ", \`" + textBox3.Text + "\`, \`" + textBox4.Text + "\`);"; MessageBox.Show(query); OleDbConnection myConnection = new OleDbConnection(connString); OleDbCommand myCommand = new OleDbCommand(query, myConnection); myConnection.Open(); OleDbDataReader myReader = myCommand.ExecuteReader(); } catch (Exception ex) { MessageBox.Show(ex.StackTrace); }
That code works just fine when I use select, but when I change it into insert it throws an ORA-00911 Invalid Character error at this code
OleDbDataReader myReader = myCommand.ExecuteReader();
Can anyone help me, please? -
I'm using c# and trying to access oracle here's my code:
try { String connString = "Provider=MSDAORA;Data Source=127.0.0.1;User id=system;Password=akar;"; string query = "insert into test values(" + textBox2.Text + ", \`" + textBox3.Text + "\`, \`" + textBox4.Text + "\`);"; MessageBox.Show(query); OleDbConnection myConnection = new OleDbConnection(connString); OleDbCommand myCommand = new OleDbCommand(query, myConnection); myConnection.Open(); OleDbDataReader myReader = myCommand.ExecuteReader(); } catch (Exception ex) { MessageBox.Show(ex.StackTrace); }
That code works just fine when I use select, but when I change it into insert it throws an ORA-00911 Invalid Character error at this code
OleDbDataReader myReader = myCommand.ExecuteReader();
Can anyone help me, please?Is it because you have copied and pasted your code from some kind of word processing program, and your single quotes are special characters rather than standard single quotes?
Reminiscing just isn't what it used to be!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
-
Is it because you have copied and pasted your code from some kind of word processing program, and your single quotes are special characters rather than standard single quotes?
Reminiscing just isn't what it used to be!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
well, I've tried using "
'
" but it doesn't work either -
well, I've tried using "
'
" but it doesn't work eitherOh, hang on... you haven't listed the fields for your insert into... insert into test (field1, field2, field3) values (...);
Reminiscing just isn't what it used to be!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
-
Oh, hang on... you haven't listed the fields for your insert into... insert into test (field1, field2, field3) values (...);
Reminiscing just isn't what it used to be!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
Here, I've changed my code into this:
string query = "insert into test(no, name, dob) values(" + textBox2.Text + ", '" + textBox3.Text + "', '" + textBox4.Text + "');";
But I still got the error -ps:column
no
is int others are varcharA hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
-
Here, I've changed my code into this:
string query = "insert into test(no, name, dob) values(" + textBox2.Text + ", '" + textBox3.Text + "', '" + textBox4.Text + "');";
But I still got the error -ps:column
no
is int others are varcharA hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
Hmmm... have you tried executing your sql directly to check that it's working as you expect?
Reminiscing just isn't what it used to be!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
-
Hmmm... have you tried executing your sql directly to check that it's working as you expect?
Reminiscing just isn't what it used to be!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
yep, it works in sql -ps:fyi, that code works when a button is clicked. after I've changed it into showing the query it shows this
insert into test(no, name, dob) values(23, 'sawqwd', '322');
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
-
yep, it works in sql -ps:fyi, that code works when a button is clicked. after I've changed it into showing the query it shows this
insert into test(no, name, dob) values(23, 'sawqwd', '322');
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
Well, if the code works when the button is clicked, and the sql works if you copy/paste it into Oracle and run it directly, there must be an error in the calling of the querydef... Do you have the correct syntax, parameters, names etc?
Reminiscing just isn't what it used to be!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
-
Well, if the code works when the button is clicked, and the sql works if you copy/paste it into Oracle and run it directly, there must be an error in the calling of the querydef... Do you have the correct syntax, parameters, names etc?
Reminiscing just isn't what it used to be!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
Silly me, I actually only need to remove the semicolon and it works :omg:
string query = "insert into test(no, name, dob) values(" + textBox2.Text + ", '" + textBox3.Text + "', '" + textBox4.Text + "')";
Guess that would mean no semicolons when connecting from c# huh? :doh: It's so different from J2SE, :laugh: Thank for the assistance :)
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
modified on Thursday, May 26, 2011 1:50 AM
-
Silly me, I actually only need to remove the semicolon and it works :omg:
string query = "insert into test(no, name, dob) values(" + textBox2.Text + ", '" + textBox3.Text + "', '" + textBox4.Text + "')";
Guess that would mean no semicolons when connecting from c# huh? :doh: It's so different from J2SE, :laugh: Thank for the assistance :)
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
modified on Thursday, May 26, 2011 1:50 AM
Dammit... the semicolon was the first thing I was going to mention, but when I checked oracle sql syntax it was there... :sigh: Glad you got it fixed!!
Reminiscing just isn't what it used to be!! Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!
-
Silly me, I actually only need to remove the semicolon and it works :omg:
string query = "insert into test(no, name, dob) values(" + textBox2.Text + ", '" + textBox3.Text + "', '" + textBox4.Text + "')";
Guess that would mean no semicolons when connecting from c# huh? :doh: It's so different from J2SE, :laugh: Thank for the assistance :)
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
modified on Thursday, May 26, 2011 1:50 AM
-
Silly me, I actually only need to remove the semicolon and it works :omg:
string query = "insert into test(no, name, dob) values(" + textBox2.Text + ", '" + textBox3.Text + "', '" + textBox4.Text + "')";
Guess that would mean no semicolons when connecting from c# huh? :doh: It's so different from J2SE, :laugh: Thank for the assistance :)
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
modified on Thursday, May 26, 2011 1:50 AM
Firo Atrum Ventus wrote:
Guess that would mean no semicolons when connecting from c# huh?
Conceptually you are executing a 'statement'. That is implicit. The semi-colon is superfluous in that context. You can however construct a statement which is composed of other statements. In that case the internal statements would require a semi-colon.
-
Firo Atrum Ventus wrote:
Guess that would mean no semicolons when connecting from c# huh?
Conceptually you are executing a 'statement'. That is implicit. The semi-colon is superfluous in that context. You can however construct a statement which is composed of other statements. In that case the internal statements would require a semi-colon.
Nah, I've tried that too. It didn't work. :confused:
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
-
Nah, I've tried that too. It didn't work. :confused:
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
-
Firo Atrum Ventus wrote:
Nah, I've tried that too. It didn't work.
You would need to post what didn't work.
Everything's the same as above except this line
string query = "insert into test values(" + textBox2.Text + ", `" + textBox3.Text + "`, `" + textBox4.Text + "`);";
changed into
string query = "insert into test values(" + textBox2.Text + ", `" + textBox3.Text + "`, `" + textBox4.Text + "`);select * from test";
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind
-
Everything's the same as above except this line
string query = "insert into test values(" + textBox2.Text + ", `" + textBox3.Text + "`, `" + textBox4.Text + "`);";
changed into
string query = "insert into test values(" + textBox2.Text + ", `" + textBox3.Text + "`, `" + textBox4.Text + "`);select * from test";
A hidden needle is way more effective than an unsheathed sword. That is, in the hand of professionals. What about you? Just pray your enemies are blind