易截截图软件、单文件、免安装、纯绿色、仅160KB

为啥我插入access数据库有问题

string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
        string sql = "insert into times(time) values('" + DateTime.Now + "' )";
        OleDbConnection con = new OleDbConnection(connectionString);
        OleDbCommand cmd = new OleDbCommand(sql, con);
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();

报错 string sql = "insert into times(time) values('" + DateTime.Now + "' )";
有错误,但是我在ACCESS数据库里面就没问题

string sql = "insert into times(time) values('" + DateTime.Now + "' )";

程序里面的格式与数据库里的格式是不相同的,要转下,

string sql = "insert into times([time]) values(#" + DateTime.Now + "# )";
试试

values('" + DateTime.Now + "' )";

string sql = "insert into times([time]) values(#" + DateTime.Now + "# )";


相关问答:

如何通过ADO使用聚合函数来查询(数据库为ACCESS)

_RecordsetPtr CMyAdo::SelectRecord(string &where, string &tablename,string &field, int way )
{
    int ret = 0;
  _RecordsetPtr pset;
CString  sql;
& ......

怎样清除ACCESS缓存

怎样清除ACCESS缓存
ACCESS版有点冷清
这个哪位高人会
小弟急用
不会 SORRY

话说楼主 我在SQL的第一个问题都是你解决的 谢谢你 我印象深刻

引用
不会 SORRY

话说楼主 我在SQL的第一 ......

ACCESS记录删除后还能查询到

用ADO操作Access数据库,为什么把记录删除之后,还能再查询出来?

链接语句 Provider=Microsoft.Jet.OLEDB.4.0;Data Source= 'MyDataBase'
删除语句 delete from MyTable where ID = 100

1. ......

关于sql里的语句与access里语句问题

我在SQL2000中下面的这句是没问题的,可到了access里就会了错
select max(classname) as classname,max(parentpath) as parentpath,max(rootid) as rootid,max(classid) as classid from prodclass where parentpa ......

如何把这句改成在access里正常运行的?

select max(classname) as classname,max(parentpath) as parentpath,max(rootid) as rootid,max(classid) as classid from prodclass where parentpath like '%0,3%' and Child=0 group by classname order ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号