首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

invalid pointer operation的异常 c++builder

2013-01-18 
invalid pointer operation的错误c++builder我在goodsForm的头文件里定义了str1~str7来接收goodsForm下输

invalid pointer operation的错误 c++builder
我在goodsForm的头文件里定义了str1~str7来接收goodsForm下输入的七个数据。再在此Form下使用。
str2~str4分别接收一个年,月,日;
str5~str7分别接收另一个年,月,日;
但在本窗体下我需要年/月/日 这样的形式。因此我用StrCat来实现。ShowMessage出来p4,q4是正确的 ,但运行到下一步就出现了“invalid pointer operation”的错误是怎么回事呢???
void __fastcall Tqingdan::FormCreate(TObject *Sender)
{
   String p1,p2,p3,p4,q1,q2,q3,q4;
   String d="/";
   p1=StrPas(StrCat(goodsForm->str2.c_str(),d.c_str()));
   p2=StrPas(StrCat(p1.c_str(),goodsForm->str3.c_str()));
   p3=StrPas(StrCat(p2.c_str(),d.c_str()));
   p4=StrPas(StrCat(p3.c_str(),goodsForm->str4.c_str()));
   //ShowMessage(p4);
   q1=StrPas(StrCat(goodsForm->str5.c_str(),d.c_str()));
   q2=StrPas(StrCat(q1.c_str(),goodsForm->str6.c_str()));
   q3=StrPas(StrCat(q2.c_str(),d.c_str()));
   q4=StrPas(StrCat(q3.c_str(),goodsForm->str7.c_str()));
   //ShowMessage(q4);
   ADOQuery1->Close();
   ADOQuery1->SQL->Clear();
   ADOQuery1->SQL->Text="Select * from dbo.sale where salgname='"+goodsForm->str1+"' and saltime between '"+p4+"' and '"+q4+"'";
   ADOQuery1->ExecSQL();
   ADOQuery1->Active=true;

}
[解决办法]
是哪一行代码出错了
[解决办法]
好好的+不用,用什么strcat?
[解决办法]
ADOQuery1->ExecSQL();
    ADOQuery1->Active=true;
换成ADOQuery1->Open();
[解决办法]
WideString/AnsiString.c_str()返回的指针,不要缓存,不要修改内容。否则后果自负。
按2楼说的用+.
String A = "123";
String B = "abc";

String C = A+"..."+B;

热点排行