C# access数据库 insert into 日期
DateTimedateTime=newDateTime();dateTime=DateTime.Now;stringstrSql3="insertintotb_Admi...
DateTime dateTime = new DateTime();
dateTime = DateTime.Now;
string strSql3 = "insert into tb_Admin ([UserName],[UserRank],[Mailbox],[UserAccount],[UserPassword],[UserNowOnlineTime]) valuse ( '" + tbname.Text + "','" + tbaccount.Text + "','" + tbrank.Text + "','" + tbemail.Text + "','000000','" + dateTime + "')";
我添加了一个日期到ACCESS数据中,程序运行时错误提示是:INSERT INTO 语句的语法错误。请问我要怎样解决问题?(在update语句中使用dateTime没有报错,也能更新成功) 展开
dateTime = DateTime.Now;
string strSql3 = "insert into tb_Admin ([UserName],[UserRank],[Mailbox],[UserAccount],[UserPassword],[UserNowOnlineTime]) valuse ( '" + tbname.Text + "','" + tbaccount.Text + "','" + tbrank.Text + "','" + tbemail.Text + "','000000','" + dateTime + "')";
我添加了一个日期到ACCESS数据中,程序运行时错误提示是:INSERT INTO 语句的语法错误。请问我要怎样解决问题?(在update语句中使用dateTime没有报错,也能更新成功) 展开
3个回答
展开全部
试试在strSql3中,将dateTime改成 dateTime.ToString( ),修改后如下:
string strSql3 = "insert into tb_Admin ([UserName],[UserRank],[Mailbox],[UserAccount],[UserPassword],[UserNowOnlineTime]) valuse ( '" + tbname.Text + "','" + tbaccount.Text + "','" + tbrank.Text + "','" + tbemail.Text + "','000000','" + dateTime.ToString( ) + "')";
string strSql3 = "insert into tb_Admin ([UserName],[UserRank],[Mailbox],[UserAccount],[UserPassword],[UserNowOnlineTime]) valuse ( '" + tbname.Text + "','" + tbaccount.Text + "','" + tbrank.Text + "','" + tbemail.Text + "','000000','" + dateTime.ToString( ) + "')";
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
拼写错误 values
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询