本文介绍了日期查询表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
日期数据类型字段的正确查询表达式是什么,以便使用OleDBCommand在MS Access SQL中进行选择和更新,真的,我已经厌倦了尝试
Whats the correct query expression for date datatype field in order to select and update in MS Access SQL using OleDBCommand, realy i am get tired of trying
谢谢
推荐答案
System.Data.OleDb.OleDbConnection AccessConn = new System.Data.OleDb.OleDbConnection(("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=C:\\Test Files\\db1 XP.mdb;"));
AccessConn.Open();
System.Data.OleDb.OleDbCommand AccessCommand = new System.Data.OleDb.OleDbCommand("INSERT INTO [TableName] (ID, CreateDate) VALUES (@ID, @DateVal)", AccessConn);
System.DateTime DateValue = 9/30/2011 12:00:00 AM;
AccessCommand.Parameters.AddWithValue("@ID", 12345);
AccessCommand.Parameters.AddWithValue("@DateVal", DateValue);
AccessCommand.ExecuteNonQuery();
AccessConn.Close();
这篇关于日期查询表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!