S
springhill
Unregistered / Unconfirmed
GUEST, unregistred user!
公司要用BCB做多层的开发,我是用李维的书来学习的,但公司现在只有我在做这一块的贮备工作,没有人交流,遇到了很大的困难,如下问题如何解决(例子程序):
服务端:
STDMETHODIMP TDynamicSQLDemoServerImpl::GetAllTables(VARIANT* vTables)
{
TStringList *tblList=new TStringList();
try
{
DynamicSQLDemoServer->ADOConnection1->GetTableNames(tblList);
const int tblcnt=tblList->Count;
ShowMessage(IntToStr(tblcnt));
int bounds[2]={0,tblcnt-1};
vTables=VarArrayCreate(bounds,tblcnt,varVariant);
for (int i=0;i<tblcnt;++i)
{
vTables=(Variant)tblList->Strings;
}
ShowMessage(IntToStr(VarArrayHighBound(vTables,1)));
}
__finally
{
delete tblList;
}
return S_OK;
}
客户端:
void __fastcall TForm2::btnConnectClick(TObject *Sender)
{
Variant vtblList;
SocketConnection1->Connected=true;
IDispatch* disp = (IDispatch*)(SocketConnection1->AppServer);
IDynamicSQLDemoServerDisp TempInterface((IDynamicSQLDemoServer*)disp);
TempInterface.GetAllTables(vtblList);
//ShowMessage(VarToStr(vtblList));
if (VarIsArray(vtblList))
{
ShowMessage("Is Array");
for (int i=VarArrayLowBound(vtblList,1);i<=VarArrayHighBound(vtblList,1);++i)
{
lbTables->Items->Add((&vtblList));
}
}
else
{
ShowMessage("Is not Array");
}
}
没有效果,请做过多层开发的或照着李维书学习的BCBer帮我解决一下。
服务端:
STDMETHODIMP TDynamicSQLDemoServerImpl::GetAllTables(VARIANT* vTables)
{
TStringList *tblList=new TStringList();
try
{
DynamicSQLDemoServer->ADOConnection1->GetTableNames(tblList);
const int tblcnt=tblList->Count;
ShowMessage(IntToStr(tblcnt));
int bounds[2]={0,tblcnt-1};
vTables=VarArrayCreate(bounds,tblcnt,varVariant);
for (int i=0;i<tblcnt;++i)
{
vTables=(Variant)tblList->Strings;
}
ShowMessage(IntToStr(VarArrayHighBound(vTables,1)));
}
__finally
{
delete tblList;
}
return S_OK;
}
客户端:
void __fastcall TForm2::btnConnectClick(TObject *Sender)
{
Variant vtblList;
SocketConnection1->Connected=true;
IDispatch* disp = (IDispatch*)(SocketConnection1->AppServer);
IDynamicSQLDemoServerDisp TempInterface((IDynamicSQLDemoServer*)disp);
TempInterface.GetAllTables(vtblList);
//ShowMessage(VarToStr(vtblList));
if (VarIsArray(vtblList))
{
ShowMessage("Is Array");
for (int i=VarArrayLowBound(vtblList,1);i<=VarArrayHighBound(vtblList,1);++i)
{
lbTables->Items->Add((&vtblList));
}
}
else
{
ShowMessage("Is not Array");
}
}
没有效果,请做过多层开发的或照着李维书学习的BCBer帮我解决一下。