Sql命令INSERT正在运行,但数据未出现在数据库中 [英] Sql command INSERT is working but the data not appear in tha DATABASE

查看:88
本文介绍了Sql命令INSERT正在运行,但数据未出现在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void OpenConnexion()
        {
            try
            {
                 conn = new SqlConnection(@"Data Source=RAJ;Initial Catalog=GENIUS;Integrated Security=True");
                
                
                conn.Open();
            }
            catch (Exception e)
            {
                MessageBox.Show("Erreur de Connexion de la base");

            }


        }

public void InsertLP(LignePiece LP)
        {
            OpenConnexion();

            cmd = new SqlCommand("INSERT INTO F_LIGNEPIECE (EP_No,EP_Date,EP_Reference,EP_Tiers,CT_Intitule,AR_Ref,AR_Design,LP_QteMvt,LP_ValeurRemise,LP_TypeRemise,LP_TTC,LP_MontantHT,LP_MontantTTC,LP_PrixUnitaire,LP_PUTTC,LP_CodeTaxeTVA,LP_TauxTVA,N_CatCompta) VALUES" +
                                 " (,@EP_No,@EP_Date,@EP_Reference,@EP_Tiers,@CT_Intitule,@AR_Ref,@AR_Design,@LP_QteMvt,@LP_ValeurRemise,@LP_TypeRemise,@LP_TTC,@LP_MontantHT,@LP_MontantTTC,@LP_PrixUnitaire,@LP_PUTTC,@LP_CodeTaxeTVA,@LP_TauxTVA,@N_CatCompta,)", conn);
              cmd.Parameters.Add("@EP_No", LP.EP_No);
          
            cmd.Parameters.Add("@EP_Date", LP.EP_Date);
            cmd.Parameters.Add("@EP_Reference", LP.EP_Reference);
            cmd.Parameters.Add("@EP_Tiers", LP.EP_Tiers);
            cmd.Parameters.Add("@CT_Intitule", LP.CT_Intitule);
            cmd.Parameters.Add("@AR_Ref", LP.AR_Ref);
            cmd.Parameters.Add("@AR_Design", LP.AR_Design);
            cmd.Parameters.Add("@LP_QteMvt", LP.LP_QteMvt);
            cmd.Parameters.Add("@LP_ValeurRemise", LP.LP_ValeurRemise);
            cmd.Parameters.Add("@LP_TypeRemise", LP.LP_TypeRemise);
            cmd.Parameters.Add("@LP_TTC", LP.LP_TTC);
            cmd.Parameters.Add("@LP_MontantHT", LP.LP_MontantHT);
            cmd.Parameters.Add("@LP_MontantTTC", LP.LP_MontantTTC);
            cmd.Parameters.Add("@LP_PrixUnitaire", LP.LP_PrixUnitaire);
            cmd.Parameters.Add("@LP_PUTTC", LP.LP_PUTTC);
            cmd.Parameters.Add("@LP_CodeTaxeTVA", LP.LP_CodeTaxeTVA);
            cmd.Parameters.Add("@LP_TauxTVA", LP.LP_TauxTVA);
            cmd.Parameters.Add("@N_CatCompta",LP.N_CatCompta);
            cmd.ExecuteNonQuery();
            conn.Close();
        }





我的尝试:



我有另一个视图和插入到同一个数据库GENIUS它一切正常,但这个不是。它没有显示任何错误,但我找不到结果到SQL-Server表



What I have tried:

I have another views and Inserts into the same Database "GENIUS "it all works but this one is not . It did not show any error but i can't find the results into SQL-Server Table

推荐答案

我打赌它确实显示错误:你的值列表以逗号开头应该是语法错误:

I'm betting it does show an error: your list of values starts with a comma which should be a syntax error:
... VALUES" +
" (,@EP_No, ...

使用调试器单步执行ExecuteNonQuery行,我认为您会发现异常。

Use the debugger to single step the ExecuteNonQuery line, and I think you'll find you get an exception.


这篇关于Sql命令INSERT正在运行,但数据未出现在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆