zoukankan      html  css  js  c++  java
  • Oracle SQL 插入语句中包含有时间问题

    using System;
    using System.Collections;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Linq;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Data.OleDb;
    
    namespace WebApplication1
    {
        /// <summary>
        /// $codebehindclassname$ 的摘要说明
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        public class updata : IHttpHandler
        {
    
            string StrConntion = "Provider=MSDAORA.1;Data Source=218;Persist Security Info=True;User ID=train;Password=jptrain";
            OleDbConnection con = null;
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
                context.Response.ContentType = "utf-8";
                string CarNo = context.Request["CarNo"];
                string Pic_Time = context.Request["Pic_Time"];
                string STATE = context.Request["STATE"];
                string OTHER = context.Request["OTHER"];
                string enterprisename = context.Request["enterprisename"];
                string time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                string OID = "CK" + DateTime.Now.ToString("yyyyMMddhhmmss");
                using (con = new OleDbConnection(StrConntion))
                {
                    string sql = "insert into camera_check (OID,CARTNO,ENTERPRISENAME,STATE,OTHER,TIME,TAKE_IMG_TIME) VALUES('"
                        + OID + "','" + CarNo + "','" + enterprisename + "','" + STATE + "','" + OTHER + "',to_date('" + time + "','yyyy-mm-dd hh24:mi:ss'),'" + Pic_Time + "')";
                    OleDbCommand cmd = new OleDbCommand(sql, con);
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                    cmd.Dispose();
                }
            }
    
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }

    时间一定要这样写:  to_date('2012-4-23 4:19:33','yyyy-mm-dd hh24:mi:ss')
    如:Insert Into Good (time) Values(to_date('2012-4-23 4:19:33','yyyy-mm-dd hh24:mi:ss'));

  • 相关阅读:
    猫与路由器(还没看)
    ORA-12154: TNS: 无法解析指定的连接标识符(未解决)
    easy-batch demo
    mongodb 创建用户
    docker mongodb
    监听器,过滤器,拦截器
    mysql docker-compose启动异常:Database is uninitialized and password option is not specified
    设计模式-builder模式的价值
    【C++ Template | 04】折叠表达式
    【vim】vim插件教程
  • 原文地址:https://www.cnblogs.com/xgxhellboy/p/2466666.html
Copyright © 2011-2022 走看看