0

I've the following vb.net function which have a syntax error in the sql commandtext that i can't seem to figure out

Private Sub addsupporderidsinbookedtoinprocess()
        Try
            Dim cnn3 As New SqlConnection(connetionString)
            Dim sqlcmd3 As New SqlCommand("SELECT supporderidinprocess FROM ordersinprocess", cnn3)
            sqlcmd3.CommandText = "INSERT INTO ordersinprocess(supporderidinprocess) VALUES(SELECT IDENT_CURRENT('[supporder]'))"
            cnn3.Open()
            sqlcmd3.ExecuteNonQuery()
            sqlcmd3.Parameters.Clear()
            cnn3.Close()
        Catch ex As SqlException
            MsgBox(ex.Message)
        End Try
    End Sub

the error is in this part

...VALUES(SELECT IDENT_CURRENT('[supporder]'))

any idea how to fix this?

1 Answer 1

6

There should be no VALUES keyword in INSERT INTO...SELECT statement. Try something like this,

INSERT INTO ordersinprocess(supporderidinprocess) 
SELECT IDENT_CURRENT('[supporder]')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.