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

大家帮我看一个程序吧!(从字符串转换为 smalldatetime 数据类型时发生语法错误。 )
string   pro_id   =   Request.QueryString[ "pro_id "].ToString().Trim();
                string   pro_title   =   TextBox1.ToString().Trim();
                string   deadline   =   TextBox4.ToString();
                string   run_time   =   TextBox5.ToString();
                string   content   =   TextBox6.ToString();

                if   (   pro_title   ==   " "   ||   deadline   ==   " "   ||   run_time   ==   " "   ||   content   ==   " "   )
                {
                        Response.Write( " <script> alert( '请完善项目信息! '); </script> ");
                        Response.Write( " <script> window.history.go(-1); </script> ");
                        return;
                }
                string   comText   =   "UPDATE   Program   SET   isPass= '批准 ',deadline   =   ' "   +   deadline   +   " ',   pro_title   =   ' "   +   pro_title   +   " ',   run_time   =   ' "   +   run_time   +   " ',   content   =   ' "   +   content   +   " '   WHERE   pro_id   =   ' "   +   pro_id   +   " ' ";
                SqlConnection   myConnection   =   new   SqlConnection();
                myConnection.ConnectionString   =   SQLCONNECTIONSTRING;
                SqlCommand   myCommand   =   new   SqlCommand(comText,   myConnection);
                myConnection.Open();
                myCommand.ExecuteNonQuery();
                myConnection.Close();


------解决方案--------------------
时间格式错了吧;
------解决方案--------------------
你数据库里的字段如果是datatime的话,你最好在程序里用convert强制转换成datetime
------解决方案--------------------
the time should be day-month-year
please remember the - should be encoded in English, rather than chinese sets......