locked
how to solve missing select keyword RRS feed

  • Question

  • User1248258412 posted

    Can someone know what wrong with my code below? I trying to insert but keep showing error ora-00928 missing select keyword ?

    I did online search and follow many suggestion but still showing the same error..

    Dim strSQL As String = Nothing, paramx(1) As OleDbParameter strSQL = "Insert into tblBefLog (UID, TEST_NO) " strSQL &= " values (?,?)"

    transaction = oraConn.BeginTransaction() paramx(0) = New OleDbParameter("@UID", OleDbType.VarChar) paramx(0).Value = UID

    paramx(1) = New OleDbParameter("@TEST_NO", OleDbType.VarChar) paramx(1).Value = TEST_NO

    OleDbHelper.ExecuteNonQuery(transaction, CommandType.Text, strSQL, param) transaction.Commit()

    Wednesday, June 1, 2016 12:17 AM

Answers

  • User269602965 posted
    Public Sub InsertTransaction(ByVal connectionString as String, ByVal strUID as String, ByVal strTestNo as String)
    
        Using connection As New OleDbConnection(connectionString)
            Dim command As New OleDbCommand()
            Dim transaction As OleDbTransaction
    
            ' Set the Connection to the new OleDbConnection.
            command.Connection = connection
    
            ' Open the connection and execute the transaction.
            Try
                connection.Open()
    
                ' Start a local transaction with ReadCommitted isolation level.
                transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)
    
                ' Assign transaction object for a pending local transaction.
                command.Connection = connection
                command.Transaction = transaction
                
                ' Set the parameters.
                command.Parameters.Clear()
                command.Parameters.Add("@UID", OleDbType.VarChar).Value = strUIC
                command.Parameters.Add("@TESTNO", OleDbType.Varchar).Value = strTestNo
    
                ' Execute the commands.
                command.CommandText = "Insert into tblBefLog (UID, TEST_NO) Values (?,?) "
                command.ExecuteNonQuery()
    
                ' Commit the transaction.
                transaction.Commit()
                Console.WriteLine("record inserted to database.")
    
            Catch ex As Exception
                Console.WriteLine(ex.Message)
                ' Try to rollback the transaction
                Try
                        transaction.Rollback()
    
                Catch
                    ' Do nothing here; transaction is not active.
                End Try
            End Try
        End Using
    
    End Sub
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 4, 2016 8:43 PM

All replies

  • User269602965 posted
    Public Sub InsertTransaction(ByVal connectionString as String, ByVal strUID as String, ByVal strTestNo as String)
    
        Using connection As New OleDbConnection(connectionString)
            Dim command As New OleDbCommand()
            Dim transaction As OleDbTransaction
    
            ' Set the Connection to the new OleDbConnection.
            command.Connection = connection
    
            ' Open the connection and execute the transaction.
            Try
                connection.Open()
    
                ' Start a local transaction with ReadCommitted isolation level.
                transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)
    
                ' Assign transaction object for a pending local transaction.
                command.Connection = connection
                command.Transaction = transaction
                
                ' Set the parameters.
                command.Parameters.Clear()
                command.Parameters.Add("@UID", OleDbType.VarChar).Value = strUIC
                command.Parameters.Add("@TESTNO", OleDbType.Varchar).Value = strTestNo
    
                ' Execute the commands.
                command.CommandText = "Insert into tblBefLog (UID, TEST_NO) Values (?,?) "
                command.ExecuteNonQuery()
    
                ' Commit the transaction.
                transaction.Commit()
                Console.WriteLine("record inserted to database.")
    
            Catch ex As Exception
                Console.WriteLine(ex.Message)
                ' Try to rollback the transaction
                Try
                        transaction.Rollback()
    
                Catch
                    ' Do nothing here; transaction is not active.
                End Try
            End Try
        End Using
    
    End Sub
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 4, 2016 8:43 PM
  • User-1636183269 posted

    Aoshi,

    You have forgot to mentioned "Values"

    Insert into tblBefLog VALUES (UID, TEST_NO)

    Sunday, June 5, 2016 1:18 PM