Question

I am having three columns in my table branch i.e id(Autonumber),code(text),desc(text).I am trying to execute this sql insert into branch(code,desc) values('"+b+"','"+c+"')"; which gives me error syntax error..please help

Was it helpful?

Solution

One of your columns has name DESC, which is Reserved Keyword. In order to peoperly execute the INSERT statement, you need to delimite the column by using brackets eg

insert into branch(code,[desc]) values ('"+b+"','"+c+"')";

One more thing, your code is prone to SQL Injection. Please do parameterized the query.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top