问题描述
- MFC添加数据insert语句出错
-
代码中写了一条插入语句,如下:strSql.Format(_T("INSERT INTO Bill_Info
(Bill_ID,Buyer_Name,Buyer_Book,Buyer_State,Price)
values('%s','%s','s','%d','%f')"),
b.getbid(),b.getbname(),b.getbbook(),b.getbstate(),b.getprice());
调用 pRst->Update();时报错,加了断点发现
语句显示的是:- strSql L"INSERT INTO Bill_Info (Bill_ID,Buyer_Name,Buyer_Book,Buyer_State,Price) values('?x18','癮污摩猠牴湩?潰楳楴湯?????????????','s','-858993460','-92559631349317831000000000000000000000000000000000000000000000.000000'... ATL::CStringT > >
请问,什么原因,怎么解决
- strSql L"INSERT INTO Bill_Info (Bill_ID,Buyer_Name,Buyer_Book,Buyer_State,Price) values('?x18','癮污摩猠牴湩?潰楳楴湯?????????????','s','-858993460','-92559631349317831000000000000000000000000000000000000000000000.000000'... ATL::CStringT > >
解决方案
values('%s','%s','%s','%d','%f') //少个%
解决方案二:
strSql.Format(_T("INSERT INTO Bill_Info
(Bill_ID,Buyer_Name,Buyer_Book,Buyer_State,Price)
values('%s','%s','s','%d','%f')", 这里参数呢),
解决方案三:
把这几个参数用逗号隔开写在后面
解决方案四:
你的参数字符编码是什么。乱码应该是编码不对
解决方案五:
发现了,是少了个%,谢各位啦
解决方案六:
SQL语言使用insert语句向数据库表格中插入或添加新的数据行
时间: 2024-12-31 20:14:28