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

  • 相关阅读:
    C#:友元程序集
    C#/Net代码精简优化技巧(3)
    Net4.0AspNet中URL重写的改进
    JQuery boxy插件的确认框在AspNet中的应用
    在数据库中将字表中的多行合并到一列中
    软件推荐:磁盘搜索软件Everything
    Net4.0对HTML净化的处理
    C#/Net代码精简优化技巧(2)
    推荐两款富文本编辑器:NicEdit和Kindeditor
    ASP.NET MVC+EF框架+EasyUI实现权限管理系列(11)验证码实现和底层修改
  • 原文地址:https://www.cnblogs.com/xgxhellboy/p/2466666.html
Copyright © 2020-2023  润新知