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