为啥我插入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 + "# )";
相关问答:
_RecordsetPtr CMyAdo::SelectRecord(string &where, string &tablename,string &field, int way )
{
int ret = 0;
_RecordsetPtr pset;
CString sql;
& ......
怎样清除ACCESS缓存
ACCESS版有点冷清
这个哪位高人会
小弟急用
不会 SORRY
话说楼主 我在SQL的第一个问题都是你解决的 谢谢你 我印象深刻
引用
不会 SORRY
话说楼主 我在SQL的第一 ......
用ADO操作Access数据库,为什么把记录删除之后,还能再查询出来?
链接语句 Provider=Microsoft.Jet.OLEDB.4.0;Data Source= 'MyDataBase'
删除语句 delete from MyTable where ID = 100
1. ......
我在SQL2000中下面的这句是没问题的,可到了access里就会了错
select max(classname) as classname,max(parentpath) as parentpath,max(rootid) as rootid,max(classid) as classid from prodclass where parentpa ......
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 ......