Oracle ExecuteNonQuery Error invalid character, but for other sql database system is good

Oracle SQL ExecuteNonQuery Error invalid character, but for other sql database system is good.

The code is working fine in MySql, MsSql, FirebirdSql.
And also work in Oracle SQL Plus when inserting a command like:
INSERT INTO TEST(number1,number2,string1) VALUES(1,1,'a');

Whats in oracle? Why this code errors an invalid character in ExecuteNonQuery()?
Any suggestion of the code for oracle?
Or perhaps edit the code for sure.

Honestly I hate oracle system database, but the company requires to use it.
Hmp!


Private lConStr As String = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=FINGER)));User Id=myuser;Password=mypassword;"       ''''''glova private variable
 
Protected lmyconn As OracleConnection   '''''gloval variable
Protected lmyComIUD As New OracleCommand ''''global variable
 
Private OpenDBs...................      ''''called during form opened.
lmyconn = New OracleConnection()
lmyconn.ConnectionString = lConStr
lmyconn.Open()
lmyComIUD.Connection = lmyconn
End Sub
 
Private sub Saving_Click...................................  ''''called when clicked
 
     Dim sqlIUD As String ''''private variable
     sqlIUD = "INSERT into test(number1,number2,string1) VALUES(?a?b?c)"
 
     lmyComIUD.Parameters.Add("?a", 2)
     lmyComIUD.Parameters.Add("?b", 2)
     myComIUD.Parameters.Add("?c", "b")
 
     lmyComIUD.CommandType = CommandType.Text
     lmyComIUD.CommandText = sqlIUD
 
     lmyComIUD.ExecuteNonQuery() '''''error invalid character. works in mysql,mssql
 
 
End Sub

Open in new window

LVL 12
rionrocAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
remove the ";" at the end.
rionrocAuthor Commented:
Hello

Thanks for the quick reply.

I did not put any ;

Except this: but works fine.
And also work in Oracle SQL Plus when inserting a command like:
INSERT INTO TEST(number1,number2,string1) VALUES(1,1,'a');

But in .Net it didn't.
Please see the code.


Great is our GOD.
:)
SujithData ArchitectCommented:
Shouldn't this statement
>> sqlIUD = "INSERT into test(number1,number2,string1) VALUES(?a?b?c)"

be like this?

sqlIUD = "INSERT into test(number1,number2,string1) VALUES(?a, ?b, ?c)"
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

rionrocAuthor Commented:
Hello


Thanks for that.


But its not working too.



Great is our GOD.
:)
SujithData ArchitectCommented:
Generally bind variables are prefixed with a colon, I am not sure about the usage in .net.

Try to use colons instead of the question marks for the bind variables. Something like

sqlIUD = "INSERT into test(number1,number2,string1) VALUES(:a, :b, :c)"
     lmyComIUD.Parameters.Add(":a", 2)
     lmyComIUD.Parameters.Add(":b", 2)
     myComIUD.Parameters.Add(":c", "b")
 

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rionrocAuthor Commented:
Hello


Thanks for that.


But its not working too.



Great is our GOD.
:)
SujithData ArchitectCommented:
Well, the add parameter portion didn't have to use the colons by the way.
Try this

sqlIUD = "INSERT into test(number1,number2,string1) VALUES(:a, :b, :c)"
     lmyComIUD.Parameters.Add("a", 2)
     lmyComIUD.Parameters.Add("b", 2)
     myComIUD.Parameters.Add("c", "b")
Guy Hengel [angelIII / a3]Billing EngineerCommented:
rionroc,

> But its not working too.
is a bit few feedback. some error message should be helpful.

try to help us help you!

but I think that sujith80 has got it, now...
rionrocAuthor Commented:
Ops!

>>but I think that sujith80 has got it, now...
Yes, it's working fine now.

Sorry, I did not recognize it, because some error comes out after that command:

Public Function Savedid() as integer
 
     Dim sqlIUD As String ''''private variable
     sqlIUD = "INSERT into test(number1,number2,string1) VALUES(:a,:b,:c)"
 
     lmyComIUD.Parameters.Add(":a", 2)
     lmyComIUD.Parameters.Add(":b", 2)
     myComIUD.Parameters.Add(":c", "b")
 
     lmyComIUD.CommandType = CommandType.Text
     lmyComIUD.CommandText = sqlIUD
 
     lmyComIUD.ExecuteNonQuery() '''works fine now because of : only :)


Dim did As Integer
Dim idCMD As OracleCommand = New OracleCommand("SELECT @@IDENTITY", lmyconn)
did = CInt(idCMD.ExecuteScalar()) ''''error was ORA-00936: missing expression '''
 
Return did

End Sub



Great is our GOD.
:)
SujithData ArchitectCommented:
i dont understand.
what is not working now?

if you are referring to this statement
>>Dim idCMD As OracleCommand = New OracleCommand("SELECT @@IDENTITY", lmyconn)
It is not a valid SQL statement. An sql statement should have a SELECT and FROM part for the minimum.
rionrocAuthor Commented:
Thanks :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.