\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 服务端
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\1.Oracle中创建表
登陆system/manager
Create table Customer(
CustID integer,
CustName varchar(20),
Memo varchar(200)
);
2.BCB中File/New/Multitier
CoClassName:CustInfoSvr
3.控件Data Access/DataBase
DataBaseName: CUSTINFO
DriverName:ORACLE
LoginPrompt:false
Params:
SERVER NAME=ORCL
USER NAME=SYSTEM
PASSWORD=MANAGER
4.控件Data Access/UpdateSQL:
Name:CustInfoUpdateSQL
DeleteSQL:delete Customer where CustID=:old_CustID
InsertSQL:insert into Customer values (:CustID,:CustName,:Memo)
ModifySQL:update Customer set
CustID=:CustID, CustName=:CustNamename,Memo=:Memo where
CustID=:old_CustID
5.控件Data Access/TQuery:
Name:CustInfoQuery
UpdateObject:CustInfoUpdateSQL
UpdateMode:UpdateWhereKeyOnly
DatabaseName:CUSTINFO
6.控件Midas/DataSetProvider:
Name:CustInfoProvider
Options<
DataSet:CustInfoQuery
UpdateMode:upWhereKeyOnly
7.Main窗体中构造函数
CustInfoSvr = new TCustInfoSvr (Application);
if (FindWindow (NULL, "Borland Socket Server") == NULL)
WinExec (AnsiString (ExtractFilePath(Application->ExeName)
+ "Scktsrvr.exe").c_str(), SW_SHOW);
打开Borland Socket Server并添加端口27241
程序将通过BCB的Socket Server在这个端口发布服务
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 客户端
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\1.File\New\Data Modules
Name:CustInfoData
2.Midas/SocketConnection
Name:CustInfoConnection
Address:127.0.0.1
Port:27241
ServerName:DataModuleSvr.CustInfoSvr
//注:需打开客户端和Socket Server才能选择ServerName
3.Midas/ClientDataSet
Name:CustInfoCds
RemoteServer:CustInfoConnection
ProviderName:CustInfoProvider
4.Data Access/DataSource
Name:CustInfoSource
DataSet:CustInfoCds
5.MainForm构造函数
try
{
CustInfoData->CustInfoCds->Open();
DataSource = CustInfoData->CustInfoSource;
DBGrid1->DataSource = CustInfoData->CustInfoSource;
}
catch(Exception &e)
{
ShowMessage(e.Message);
}
//配置结束
这个程序主要通过DataSetProvider来提供服务
还没有深入了解DCOM,不过我想这应该就是DCOM的一个应用
DataSetProvider只要提供一个数据集就可以提供远程调用