我在用query查询的时候遇到问题,
有些字段可以查,有些字段不可以查出。
不知道为什么?那位大大能帮忙看一下吗? ps:
我感觉是不是lunwen.dbf这个数据库中LWTW字段太长了,可是用database desktop
里的SQL editor,并RUn却是可以的。 下面是我的代码,另外附上我的project,
//--------------------------------------------------------------------------- #include
#pragma hdrstop #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString strFile;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
OpenDialog1->InitialDir=ExtractFilePath(Application->ExeName);
OpenDialog1->Filter = "DBF File(*.dbf)|*.dbf"; if(OpenDialog1->Execute())
{
if(TableMain->Active)
TableMain->Close(); TableMain->TableName=OpenDialog1->FileName;
strFile=ExtractFileName(TableMain->TableName);
strFile=ChangeFileExt(strFile,"");
Caption=strFile;
TableMain->Open();
TableMain->Active=true; DataMain->DataSet=TableMain;
DBGrid1->DataSource=DataMain;
}
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender)
{
QueryPaper->Close();
QueryPaper->SQL->Clear();
QueryPaper->SQL->Add("Select LWCJ From " strFile);
//问题在这里,当我换成下面句子就不能运行
//QueryPaper->SQL->Add("Select * From " strFile);
QueryPaper->Open();
QueryPaper->Active=true; DataMain->DataSet=QueryPaper;
DBGrid1->DataSource=DataMain;
}
//---------------------------------------------------------------------------
發表人 - zhvickie 於 2005/05/26 20:30:15