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'));

  • 相关阅读:
    使用SSIS汇集监控数据
    centos 6.7安装与配置vncserver
    MySQL问题记录--Can't connect to MySQL server on localhost (10061)解决方法
    django学习记录--第一个网页“hello django”
    【转】Python 日期和时间
    【转】Mysql中varchar存放中文与英文所占字节异同
    MySQL学习笔记--基本操作
    MySQL学习笔记--数据类型
    Linux 下安装pip
    【转】CentOS 6.5安装pyspider过程记录
  • 原文地址:https://www.cnblogs.com/xgxhellboy/p/2466666.html
Copyright © 2011-2022 走看看