Syntax error in INSERT INTO statement (Microsoft Access) -


i using visual studio 2010 connected access database (2010).

i created button add items textboxes database , i'm getting error "syntax error in insert statement"

    protected void upload_click(object sender, eventargs e) {     if (fileupload3.hasfile)     {         try         {             string filename = path.getfilename(fileupload3.filename);             fileupload3.saveas(server.mappath("images") + "/" + filename);             picture.text = "images/" + filename;             label2.text = "";         }         catch (exception ex)         {              label2.text = "upload status: file not uploaded. following error occured: " + ex.message;         }        } }  protected void addnewitem_click(object sender, eventargs e) {       accessdatasource1.insertcommand = "insert ram (ram name, picture) values ('" + name.text.tostring() + ",'" + picture.text.tostring() + "')";      accessdatasource1.insert(); } 

try bit of sql injection: append single quote text enter in "name" textbox.

and if works, use parameters in query rather appending text user.

further reading:

http://www.codinghorror.com/blog/2005/04/give-me-parameterized-sql-or-give-me-death.html

how parameterized queries against sql injection?

update

also use correction in alberto spelta's comment on original question (enclose column name contains spaces in brackets: "ram name" => "[ram name]"). syntax error omitted single quote.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -