Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.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#_Mysql - Fatal编程技术网

C# 将行从一个表复制到另一个表

C# 将行从一个表复制到另一个表,c#,mysql,C#,Mysql,我对MySQL命令中的insert和delete行有问题。我想将一行从表1复制到表2 commandSQL.CommandText = "INSERT IGNORE INTO table1 SELECT * FROM table2 WHERE simnum=@simnum AND msg=@msg;" + "DELETE FROM table1 WHERE simnum= @simnum AND msg= @msg"; commandSQL.Pr

我对MySQL命令中的insert和delete行有问题。我想将一行从
表1
复制到
表2

commandSQL.CommandText = "INSERT IGNORE INTO table1 SELECT * FROM table2 WHERE simnum=@simnum AND msg=@msg;" +
                         "DELETE FROM table1 WHERE simnum= @simnum AND msg= @msg";
commandSQL.Prepare();
commandSQL.Parameters.AddWithValue("@simnum", argumentComport[2]);
commandSQL.Parameters.AddWithValue("@msg", argumentComport[1]);

commandSQL.ExecuteNonQuery();
有人帮我吗


未执行命令INSERT和DELETE


是,我调用
Open()
。另一个SQL命令是work。但事实并非如此。
commandSQL.CommandType=CommandType.Text
-其默认设置

您的SQL看起来有点奇怪:

"INSERT IGNORE INTO table1 SELECT * FROM table2 WHERE simnum=@simnum AND msg=@msg;" +
"DELETE FROM table1 WHERE simnum= @simnum AND msg= @msg";
您将插入到表1中,然后立即从表1中删除

您还可以尝试添加
commandSQL.CommandType=CommandType.Text在顶部。
您是否也在SqlConnection对象上调用了Open


你有特例吗?希望这有帮助。

@duDE根据公认的答案,看起来这只是一个打字错误(删除
中的表1和表2)。