解析查询出错.[令牌行号,令牌行偏移量,,令牌错误,,]
本文关键字:令牌 偏移量 错误 查询 出错 | 更新日期: 2023-09-27 17:52:51
我在ExecuteNonQuery
得到一个错误,真的不知道为什么。我花了很多时间在网上搜索,意识到User
必须在[]
之间,但它并没有解决我的问题。
else {
DataTable table = new DataTable();
string query = "SELECT * FROM [User] WHERE Email = '" + tbMail.Text + "'";
OleDbDataAdapter adapter = new OleDbDataAdapter(query, connectionString);
int count = adapter.Fill(table);
if (count != 0) {
MessageBox.Show("This email is already in use", "Email in use", MessageBoxButtons.OK, MessageBoxIcon.Information);
} else {
OleDbConnection connection = new OleDbConnection(connectionString);
OleDbCommand insertCommand = new OleDbCommand();
adapter = new OleDbDataAdapter();
string encryptedPassword = Convert.ToBase64String(System.Security.Cryptography.MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(tbPass.Text)));
connection.Open();
string command = "INSERT INTO [User] (Username, Password, Email) VALUES('" + tbUser.Text + "', '" + encryptedPassword + "', " + tbMail.Text + ")";
insertCommand.Connection = connection;
insertCommand.CommandText = command;
adapter.InsertCommand = insertCommand;
adapter.InsertCommand.ExecuteNonQuery();
connection.Close();
}
}
错误是:
解析查询出错。[令牌行号,令牌行偏移量,,令牌错误,,]"
您的email值必须在引号之间,就像用户名和密码一样。