SQL INSERT - Invalid column name

前端 未结 6 1974
执念已碎
执念已碎 2021-01-22 16:34

As some of you may of seen from my previous post I\'m new to using C# to create websites (Although I have a fair bit of experience using it for Windows Forms apps). The powers t

6条回答
  •  北海茫月
    2021-01-22 17:00

    Don't know if it is a typo but the line should be:

    string sqlcode = "INSERT INTO file_uploads (upload_filename) VALUES ('"+filename+"')";

    Notice the ) after upload_filename.

    Also also added the single quotes around the filename.

    But you probably want to use a parameterized query:

    string sqlcode = "INSERT INTO file_uploads (upload_filename) VALUES (@filename)";

    Then use command.Parameters to add the actual value.

提交回复
热议问题