初学BCB,连接远程数据小程序调试时的问题
程序很简单,用ADOConnection,ADOQuery连接远程数据库,取了数据填在ListBox里
主要是报错不知啥意思,无从下手~
小弟从来没用过BCB,七拼八凑写了这么点代码,有啥问题请各位不吝赐教
这段代码编译阶段已经调通,语法没有问题,运行后点击按钮连接数据库并获取数据时出错
报错如下:
CodeGuard Log
Method called on illegally casted object
代码如下
//---------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString sqlStr="select * from [users]";
//---------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ADOConnection1->Open();
ADOQuery1->Close();
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add(sqlStr);
ADOQuery1->Open();
bool i=ADOQuery1->Eof;
if (i==false)
{
ADOQuery1->First();
ListBox1->Items->Add("all");
while (ADOQuery1->Eof!=true)
{
ListBox1->Items->Add(ADOQuery1->Fields->Fields[0]->AsString);
ADOQuery1->MoveBy(1);
}
}
}
//---------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ADOQuery1->Connection=ADOConnection1;
}
//---------------------------------------