TADOConnection *myADOConnection=new TADOConnection(NULL);
TADOQuery *myADOQuery=new TADOQuery(NULL);
TDataSetProvider *mDataSetProvider=new TDataSetProvider(NULL);
TClientDataSet *mClientDataSet=new TClientDataSet(NULL);
myADOQuery->Connection=myADOConnection;
mDataSetProvider->DataSet=myADOQuery;
mClientDataSet->ProviderName="mDataSetProvider";
mClientDataSet->SetProvider(mDataSetProvider);
myADOConnection->ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=用户名;Password=密码;Initial Catalog=数据库;Data Source=服务器";
myADOConnection->LoginPrompt=false;
myADOConnection->Open();
myADOQuery->SQL->Clear();
myADOQuery->SQL->Add("select * from tablename");
myADOQuery->Active=true;
mClientDataSet->Active=true;
String resultstr=mClientDataSet->XMLData;
myADOQuery->Active=false;
mClientDataSet->Active=false;