반응형
수정 : 어리석은 질문에 대해 사과드립니다. 집중력이 부족하고 SQL 구문을 배우고 있다는 사실 때문에 문제를 놓치게되었습니다.
원래 질문 : 여기서 무슨 일이 일어나고 있는지 전혀 모릅니다. 데이터를 삽입하는 여러 가지 방법을 시도했지만 지금까지 아무것도 작동하지 않았으며 항상 동일한 예외가 발생합니다. 문제의 원인이 무엇인지 잘 모르겠습니다. 명령 기능이 누락되었거나 구문에 문제가 있습니까?
string uName = "tess";
string uPwd = "newpassword";
int authorityLevel = 3;
try
{
mySqlCommand = mySqlConnect.CreateCommand();
mySqlCommand.CommandText = "INSERT INTO Users(UserName, UserPassword, AuthorityLevel) VALUES(\"" + uName + "\", \"" + uPwd + "\", " + authorityLevel + ";";
mySqlCommand.ExecuteNonQuery();
}
catch ((MySql.Data.MySqlClient.MySqlException e)
{
Console.WriteLine(e.Message);
}
// Output:
// 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 '' at line 1
해결 방법
닫는 꺾쇠 괄호)를 잊어 버렸습니다.
mySqlCommand.CommandText = "INSERT INTO Users(UserName, UserPassword, AuthorityLevel) VALUES(\"" + uName + "\", \"" + uPwd + "\", " + authorityLevel + ";";
이것을 이것으로 바꾸십시오
mySqlCommand.CommandText = "INSERT INTO Users(UserName, UserPassword, AuthorityLevel) VALUES(\"" + uName + "\", \"" + uPwd + "\", " + authorityLevel + ");";
그리고 여는 꺾쇠 괄호를 추가했습니다 (
catch ((MySql.Data.MySqlClient.MySqlException e)
이것을
catch (MySql.Data.MySqlClient.MySqlException e)
참조 페이지 https://stackoverflow.com/questions/21474288
반응형
'MySql' 카테고리의 다른 글
MySQL IFNULL 질문 (0) | 2020.12.11 |
---|---|
MySQL vb.net에서 mysql 데이터베이스를 업데이트하는 방법 (0) | 2020.12.11 |
MySQL 동적 파티셔닝 + CREATE AS on HIVE (0) | 2020.12.11 |
MySQL Tomcat에 Pentaho BI 5.0.1을 설치하는 방법 (0) | 2020.12.11 |
MySQL 교리 2에서 단일 개체와의 부모 자녀 관계 (0) | 2020.12.11 |
댓글