日期:2014-05-19  浏览次数:20690 次

插入数据问题~~~奇怪...高手帮帮啊~~~
在公司~~一切正常~~~
C#.ENT   数据库是SQL2005


把代码拷回家后~~改成本地的

String   conn   =   "server=localhost;database=ABCDB;uid=sa;pwd=001001 ";


改后~~页面查询~~~删除功能都好用!为什么插入不好用了...估计不是代码问题


  //   insert
.............
.............
.............
SqlCommand   cm   =   new   SqlCommand(sb.ToString(),   cn);

cm.Parameters.Add( "@OV_id ",   SqlDbType.NVarChar).Value   =   ov_id;
............
...........//页面控件   传进来   在公司都好用!
...........
cm.Parameters.Add( "@Appdate ",   SqlDbType.DateTime).Value   =   this.AppDate.Text;
...........

                                int   qy   =   cm.ExecuteNonQuery();
                                if   (qy   ==   1)
                                {
                                        MessageBox.Show( "成功插入一条加班记录! ");
                                        this.Empty();
                                }
                        }
                        catch   (Exception   ex)
                        {
                                MessageBox.Show( "插入失败! ");
                        }
                        finally
                        {
                                cn.Close();
                        }


try   catch   去掉后   提示       int   qy   =   cm.ExecuteNonQuery();   这行有错误

为什么插不进去呢?.....家里安装的SQL     和公司一样的

数据库都是备份回来了!为什么插不进去了呢...

高手哥哥给指点下!谢谢了!!


------解决方案--------------------
再调试一下,还不行的话,我再帮你想想看
------解决方案--------------------
cm.Parameters.Add( "@Appdate ", SqlDbType.DateTime).Value = this.AppDate.Text;

你看看数据库的时间格式对不对,可能你的公司电脑时间与你本机的时间格式不对.