Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.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# 如何用c语言更新数据库中的多条记录#_C#_Ms Access - Fatal编程技术网

C# 如何用c语言更新数据库中的多条记录#

C# 如何用c语言更新数据库中的多条记录#,c#,ms-access,C#,Ms Access,如何使用c#更新“是/否”字段选择列? 这是我的表1和表2: 这是我的密码: connection.Open(); OleDbCommand command = new OleDbCommand("update [Table1] set [Select] = @Select, [DocumentName] = @DN where [Table1ID] = " + txtTable1ID.Text + " ", connection);

如何使用c#更新“是/否”字段选择列? 这是我的表1和表2:

这是我的密码:

            connection.Open();
            OleDbCommand command = new OleDbCommand("update [Table1] set [Select] = @Select, [DocumentName] = @DN where [Table1ID] = " + txtTable1ID.Text + " ", connection);

            command.Parameters.AddWithValue("@Select", checkBox1.Checked);
            command.Parameters.AddWithValue("@DN", "Form 137");
            command.ExecuteNonQuery();
            command.Parameters.Clear();

            command.Parameters.AddWithValue("@Select", checkBox2.Checked);
            command.Parameters.AddWithValue("@Name", "Good Moral");
            command.ExecuteNonQuery();
            command.Parameters.Clear();

            command.Parameters.AddWithValue("@Select", checkBox3.Checked);
            command.Parameters.AddWithValue("@Name", "Transcript of Record");
            command.ExecuteNonQuery();
            connection.Close()
此代码的输出为:


请注意,您的代码容易受到攻击。 决不能像这样连接SQL:
[Table1ID]=“+txtable1id.Text+”

而是使用参数化SQL,就像您对其他位所做的那样,例如“@Select”参数

(抱歉,没有足够的代表将此作为评论发布)

您遗漏了一个逗号:

"update [Table1] set [Select] = @Select, [DocumentName] = @DN where [Table1ID] = " + txtTable1ID.Text + ""

这并不能回答问题。请改为评论。很抱歉,我很想这么做,但很遗憾,我没有足够的代表。