Question help me with oracle connectivity..

Karthick Sp

New member
Joined
Dec 18, 2011
Messages
1
Programming Experience
Beginner
I get the following error when this code is executed

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim myConnection As New OracleClient.OracleConnection("Data Source=karthi;User ID=scott;Password=tiger")
Dim myInsertQuery As String = "update " + ComboBox2.Text + " set question='" + TextBox1.Text + "',unit=" + TextBox2.Text + ",diff='" + TextBox3.Text + "' where " + "qno=" + DataGridView1.CurrentRow.Cells.Item("qno").Value.ToString + ";"
Dim myCommand As New OracleClient.OracleCommand(myInsertQuery)
myCommand.Connection = myConnection
myConnection.Open()
myCommand.ExecuteOracleNonQuery(1)
myCommand.Connection.Close()


End Sub

ERROR MSG:

ORA-00911: invalid character

the connectivity is working properly....
i'm sure there is something wrong with the query plz provide solution....i tried to execute the same query in oracle 9i in the sql plus prompt it executes without any problem ...plz help...
 
Don't ever use string concatenation to insert values into SQL code. Always use parameters. Follow the Blog link in my signature and check out my post on ADO.NET Parameters to learn why and how.

Also, with regards to good coding practice, why do you have a variable named 'myInsertQuery' that contains an UPDATE statement? Also, why are you calling 'myConnection.Open()' but then calling 'myCommand.Connection.Close()'? Finally, what is this: 'myCommand.ExecuteOracleNonQuery(1)'? If you want to pass a CommandBehavior value then that's what you should be passing, not an Integer.
 
Oraclew doesnt like it when you put a semicolon on the end of your SQL statement

Remove it

And like jmc said about using parameters, read the PQ link in my signature
 

Similar threads

Latest posts

Back
Top