Hi! I have this code in my program

sqlstat= "select bookNum from booktitle"
sqlstat2="select bookNum, bookName from booklist where bookNum not in " & sqlstat & "and bookAuthor like '" ListBook.SelectedItem & "'"

but it has "Incorrect syntax near the keyword 'and'" error...
please help me with this...
response is much appreciated... thanks :)

Recommended Answers

All 4 Replies

Put a space right before the AND

I already put a space but it's still the same

You're also missing an ampersand before ListBook.SelectedItem

thanks thines01... i did it this way

sqlstat= "select bookNum from booktitle"
sqlstat2="select bookNum, bookName from booklist where bookNum not in (" & sqlstat & ") and bookAuthor like '" & ListBook.SelectedItem & "'"

just missing some characters... thank you :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.