J
jtys
Unregistered / Unconfirmed
GUEST, unregistred user!
主 题: Access+ADDOQuery:各位请帮我分析下面这段代码错误!
作 者: dqwc (江天一色)
等 级:
信 誉 值: 100
所属论坛: C++ Builder DataBase
问题点数: 50
回复次数: 5
发表时间: 2003-4-23 21:10:54
void __fastcall TForm5::BitBtn16Click(TObject *Sender)
{
AnsiString s;
s="select * From cdk Where 购带时间 between #2002-1-1#
and #2002-12-31#";
//传送信息到StatusBus
Form1 ->StatusBar1 ->SimpleText=" 正在将查询结果生成报表,需要一定时间,请稍候。。。";
Form6=new TForm6(Application);
//激活第1页
Form6 -> PageControl1 ->ActivePageIndex=0;
Form6 ->ADOQuery1 ->Close();
Form6 ->ADOQuery1 ->SQL ->Clear();
Form6 ->ADOQuery1 ->SQL ->Add(s);
// Form6 ->ADOQuery1 ->SQL ->Add(Form5 ->Memo1 ->Text);
Form6 ->ADOQuery1 ->Open();
Form6 ->QuickRep1 ->Preview();
delete Form6;
}
显示的错误为:
[C++ Error] Unit5.cpp(246): E2380 Unterminated string or character constant
[C++ Error] Unit5.cpp(247): E2379 Statement missing ;
[C++ Error] Unit5.cpp(247): E2206 Illegal character '#' (0x23)
[C++ Error] Unit5.cpp(247): E2206 Illegal character '#' (0x23)
[C++ Error] Unit5.cpp(247): E2380 Unterminated string or character constant
各位:怎么解决?谢谢!
回复人: Libran() ( ) 信誉:125 2003-04-23 21:28:00 得分:0
AnsiString s;
s="select * From cdk Where 购带时间 between #2002-1-1# and #2002-12-31#";//不要换行
//传送信息到StatBus
...
回复人: Libran() ( ) 信誉:125 2003-04-23 21:31:00 得分:0
一定要换的话:
AnsiString s;
s="select * From cdk Where 购带时间 between #2002-1-1# /
and #2002-12-31#";
//传送信息到StatBus
...
注意换行时结尾处要加上“ /”
回复人: gfh_79_0(ghf) ( ) 信誉:100 2003-04-23 21:31:00 得分:0
把s="select * From cdk Where 购带时间 between #2002-1-1#
and #2002-12-31#";
写成一行。
或者用传递参数的方法。
回复人: dqwc(江天一色) ( ) 信誉:100 2003-04-23 23:35:00 得分:0
谢谢各位,问题解决。
但是我这样修改s时出现运行期错误:
s=Form5 ->Memo1 ->Text;
(Memo1里是我输入的select * From cdk Where 购带时间 between #2002-1-1#
and #2002-12-31#)
运行期错误提示为Syntax error in WHERE clause,
难道Memo1传递给s又传递给ADOQuery1时出现同样错误,where之后的语句传递不过去?
谢谢!
----------------------------------------------
回复人: sczyq(我又...........) ( ) 信誉:97 2003-04-23 23:43:00 得分:0
还有
Form6=new TForm6(Application);
应为:
TForm6 *Form6=new TForm6(Application);
作 者: dqwc (江天一色)
等 级:
信 誉 值: 100
所属论坛: C++ Builder DataBase
问题点数: 50
回复次数: 5
发表时间: 2003-4-23 21:10:54
void __fastcall TForm5::BitBtn16Click(TObject *Sender)
{
AnsiString s;
s="select * From cdk Where 购带时间 between #2002-1-1#
and #2002-12-31#";
//传送信息到StatusBus
Form1 ->StatusBar1 ->SimpleText=" 正在将查询结果生成报表,需要一定时间,请稍候。。。";
Form6=new TForm6(Application);
//激活第1页
Form6 -> PageControl1 ->ActivePageIndex=0;
Form6 ->ADOQuery1 ->Close();
Form6 ->ADOQuery1 ->SQL ->Clear();
Form6 ->ADOQuery1 ->SQL ->Add(s);
// Form6 ->ADOQuery1 ->SQL ->Add(Form5 ->Memo1 ->Text);
Form6 ->ADOQuery1 ->Open();
Form6 ->QuickRep1 ->Preview();
delete Form6;
}
显示的错误为:
[C++ Error] Unit5.cpp(246): E2380 Unterminated string or character constant
[C++ Error] Unit5.cpp(247): E2379 Statement missing ;
[C++ Error] Unit5.cpp(247): E2206 Illegal character '#' (0x23)
[C++ Error] Unit5.cpp(247): E2206 Illegal character '#' (0x23)
[C++ Error] Unit5.cpp(247): E2380 Unterminated string or character constant
各位:怎么解决?谢谢!
回复人: Libran() ( ) 信誉:125 2003-04-23 21:28:00 得分:0
AnsiString s;
s="select * From cdk Where 购带时间 between #2002-1-1# and #2002-12-31#";//不要换行
//传送信息到StatBus
...
回复人: Libran() ( ) 信誉:125 2003-04-23 21:31:00 得分:0
一定要换的话:
AnsiString s;
s="select * From cdk Where 购带时间 between #2002-1-1# /
and #2002-12-31#";
//传送信息到StatBus
...
注意换行时结尾处要加上“ /”
回复人: gfh_79_0(ghf) ( ) 信誉:100 2003-04-23 21:31:00 得分:0
把s="select * From cdk Where 购带时间 between #2002-1-1#
and #2002-12-31#";
写成一行。
或者用传递参数的方法。
回复人: dqwc(江天一色) ( ) 信誉:100 2003-04-23 23:35:00 得分:0
谢谢各位,问题解决。
但是我这样修改s时出现运行期错误:
s=Form5 ->Memo1 ->Text;
(Memo1里是我输入的select * From cdk Where 购带时间 between #2002-1-1#
and #2002-12-31#)
运行期错误提示为Syntax error in WHERE clause,
难道Memo1传递给s又传递给ADOQuery1时出现同样错误,where之后的语句传递不过去?
谢谢!
----------------------------------------------
回复人: sczyq(我又...........) ( ) 信誉:97 2003-04-23 23:43:00 得分:0
还有
Form6=new TForm6(Application);
应为:
TForm6 *Form6=new TForm6(Application);