Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我的MS Access更新查询有什么问题?_C#_Ms Access - Fatal编程技术网

C# 我的MS Access更新查询有什么问题?

C# 我的MS Access更新查询有什么问题?,c#,ms-access,C#,Ms Access,我的问题是: string Select = "Update DC set Password = '" + txtPass.Text + "' WHERE ID ="+Convert.ToInt32(cbxDocs.SelectedIndex + 1); con = new OleDbConnection(); this.readconfile = new ReadConfigFile(); con.ConnectionString = this.readconfile.ConfigString

我的问题是:

string Select = "Update DC set Password = '" + txtPass.Text + "' WHERE ID ="+Convert.ToInt32(cbxDocs.SelectedIndex + 1);
con = new OleDbConnection();
this.readconfile = new ReadConfigFile();
con.ConnectionString = this.readconfile.ConfigString(ConfigFiles.ProjectConfigFile);
con.Open();
cmd = new OleDbCommand(Select, con);
cmd.Connection = con;
cmd.ExecuteNonQuery();
con.Close();
我不知道出了什么问题,但它给了我一条错误消息“UPDATE语句中的语法错误”。 我的表“DC”ID和Password中有两个字段,没有其他内容。

Password
将其括在方括号中,如
[Password]
,因此您的查询应该像这样开始:

"Update DC set [Password]....
考虑使用参数化查询,这会将您从

密码中解救出来
将其括在方括号中,如
[PASSWORD]
,因此您的查询应该像这样开始:

"Update DC set [Password]....

考虑使用参数化查询,这将为您节省

我认为您不需要在您的查询中使用“on”,并且几乎每个ddb中都保留了密码。 您可以使用参数来避免使用+ 前


我想你不需要在你的查询和密码是保留在几乎每一个ddb上。 您可以使用参数来避免使用+ 前


使用占位符。这些操作可以清理查询并避免可能导致的细微错误,例如密码包含
。此外,请确保“密码”或“id”不是保留字。请使用占位符。这些操作可以清理查询并避免可能导致的细微错误,例如密码包含
。另外,请确保“密码”或“id”不是保留字。谢谢你的帮助,这对我来说是新的。我会记住。谢谢你的帮助,这对我来说是新的。我会记住。