数据查询时报错:arithmetic exception,numeric overflow,or string truncation
主要代码如下,其它的略了
....
AnsiString searchEd1;
AnsiString searchEd2;
searchEd1=SearchStyleEd->Text+"%";
searchEd2=SearchStyleEd2->Text+"%";
SQLString="select * from maindbf where ";
if(SearchStyleBox->Text=="用户编号")
{
SearchStyleEd->MaxLength=16;
SQLString+=" YHBH like :TheYHBH";
}
else if(SearchStyleBox->Text=="用户姓名")
{
SearchStyleEd->MaxLength=20;
SQLString+=" YHXM like :TheYhxm";
}
else if(SearchStyleBox->Text=="用户单位")
{
SearchStyleEd->MaxLength=20;
SQLString+=" YHDW like :TheYhdw";
}
else if(SearchStyleBox->Text=="用户地址")
{
SearchStyleEd->MaxLength=20;
SQLString+=" YHDZ like :TheYhdz";
}
else
{
Curr=0;
int Leng=SQLString.Length();
SQLString=SQLString.SubString(1,Leng-6);
SQLString+=" ORDER BY YHBH ASC";
}
if(searchEd1.Length()>SearchStyleEd->MaxLength)
searchEd1=SearchStyleEd->Text;
DataModule1->MainQry->SQL->Add(SQLString);
DataModule1->MainQry->Params->Items[0]->AsString=searchEd1;
DataModule1->MainQry->Prepare();
DataModule1->MainQry->Open();
......
我选的用户姓名,输入第四个汉字的时候就会报错arithmetic exception,numeric overflow,or string truncation
大概了解是什么意思,但总找不出原因
[解决办法]
检查你的字段长度
[解决办法]
数据溢出啊?
四个中文占16个字节,你给的字段多少字节?