Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.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# 您的SQL语法有错误。。。使用near'-mat、matricule mat、qte mat、类型mat、服务、Fourniseur)值(';souris';,22555';在第1行和第27行;_C#_Mysql - Fatal编程技术网

C# 您的SQL语法有错误。。。使用near'-mat、matricule mat、qte mat、类型mat、服务、Fourniseur)值(';souris';,22555';在第1行和第27行;

C# 您的SQL语法有错误。。。使用near'-mat、matricule mat、qte mat、类型mat、服务、Fourniseur)值(';souris';,22555';在第1行和第27行;,c#,mysql,C#,Mysql,尝试在列名周围使用` private void add(string design, string matricule, string qte, string type, string service, string fournisseur) { string sql = "INSERT INTO db(designation-mat,matricule-mat,qte-mat,type-mat,service,fournisseur) VALUES (@DESIGN,@MATRICUL

尝试在列名周围使用`

private void add(string design, string matricule, string qte, string type, string service, string fournisseur)
{
    string sql = "INSERT INTO db(designation-mat,matricule-mat,qte-mat,type-mat,service,fournisseur) VALUES (@DESIGN,@MATRICULE,@QTE,@TYPE,@SERVICE,@FOURNISSEUR)";
    cmd = new MySqlCommand(sql, con);

    cmd.Parameters.AddWithValue("@DESIGN", design);
    cmd.Parameters.AddWithValue("@MATRICULE", Convert.ToInt32(matricule));
    cmd.Parameters.AddWithValue("@QTE", Convert.ToInt32(qte));
    cmd.Parameters.AddWithValue("@TYPE", type);
    cmd.Parameters.AddWithValue("@SERVICE", service);
    cmd.Parameters.AddWithValue("@FOURNISSEUR", fournisseur);

    try
    {
        con.Open();

        if (cmd.ExecuteNonQuery() > 0)
        {
            cleartxts();
            MessageBox.Show("SuccessFuly Inserted!");
        }

        con.Close();
        retrieve();
    }
}

如果使用SQL Server,则为括号[…]。

尝试在列名周围使用`:

private void add(string design, string matricule, string qte, string type, string service, string fournisseur)
{
    string sql = "INSERT INTO db(designation-mat,matricule-mat,qte-mat,type-mat,service,fournisseur) VALUES (@DESIGN,@MATRICULE,@QTE,@TYPE,@SERVICE,@FOURNISSEUR)";
    cmd = new MySqlCommand(sql, con);

    cmd.Parameters.AddWithValue("@DESIGN", design);
    cmd.Parameters.AddWithValue("@MATRICULE", Convert.ToInt32(matricule));
    cmd.Parameters.AddWithValue("@QTE", Convert.ToInt32(qte));
    cmd.Parameters.AddWithValue("@TYPE", type);
    cmd.Parameters.AddWithValue("@SERVICE", service);
    cmd.Parameters.AddWithValue("@FOURNISSEUR", fournisseur);

    try
    {
        con.Open();

        if (cmd.ExecuteNonQuery() > 0)
        {
            cleartxts();
            MessageBox.Show("SuccessFuly Inserted!");
        }

        con.Close();
        retrieve();
    }
}

如果您使用SQL Server,则它是括号[…]。

可能需要引用带有诸如
标识栏
之类的插页的列:
“标识栏”
,或反勾(
`
)或者,它是在MySQL中完成的。你能提供一个适当的描述,以便我们能够帮助你,请在你的问题中添加一个正文,而不仅仅是代码。一个标题应该让人们关注你的问题,而不是整个问题本身。好的,我将编辑标题栏,并添加一些宣传语,如
名称表
需要引用:
“名称表”
,或反勾号(
`
)或MySQL中的其他名称。您能否提供适当的说明,以便我们能够帮助您为问题添加正文,而不仅仅是代码。标题应该让人们了解您的问题,而不是整个问题本身。好的,我将编辑标题