简体   繁体   中英

Error when trying to out out data from a database

I am getting the error shown here when trying to output things:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') FROM colours.prompt_reply' at line 1

Please help

MySqlCommand cmdDatabase = new MySqlCommand("select (user_Id, project, project_feedback, when) FROM colours.prompt_reply ;",conDataBase);

i think you have an error in your command

MySqlCommand cmdDatabase = new MySqlCommand("select user_Id, project, project_feedback, when FROM your_table_name",conDataBase);

is the 'when' part of your table?

i haven't really used MySql in C# but i had used Sql Sever before i think it would work

I think your query is not formatted properly, Is "when" is a column name of your table ? If yes then

use below as

MySqlCommand cmdDatabase = new MySqlCommand("select user_Id, project, project_feedback, `when` FROM colours.prompt_reply ;",conDataBase);

As when is a keyword in MySql so if you are using that as column name then use backticks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM