ورود

View Full Version : بدست آوردن Result set دوم از ADOComaand



sasan_vm
سه شنبه 07 خرداد 1387, 10:52 صبح
سلام

اگر دستوری رو که با ADOCommand به server ارسال میکنیم بیشتر از یک Result set داشته باشد ، به نتایج بعدی چگونه دسترسی داشته باشیم ؟
برای نمونه اجرای فرمان زیر:


sp_helpdb [db_name]


2 نتیجه برمی گرداند اولی اطلاعات پایه db و دومی اطلاعات فایل های db .

با سپاس.

حمیدرضاصادقیان
سه شنبه 07 خرداد 1387, 12:41 عصر
سلام.تاجاییکه من اطلاع دارم اصلا Adocommand چیزی برای شما برنمی گردونه.شما میتونی از adodataset استفاده کنی.adocommand فقط برای execute کردن دستورات به کار میره.

sasan_vm
سه شنبه 07 خرداد 1387, 15:23 عصر
:چشمک:


Class
TADOCommand
Syntax
[Delphi] function Execute(): _Recordset; overload;
[Delphi] function Execute(var Parameters: OleVariant): _Recordset; overload;
[Delphi] function Execute(var RecordsAffected: Integer; var Parameters: OleVariant): _Recordset; overload;

حمیدرضاصادقیان
سه شنبه 07 خرداد 1387, 17:42 عصر
TADOCommand
In ADOExpress, the TADOCommand component is the VCL representation of the ADO Command object. The Command object represents a command (a query or statement) that can be processed by the data source. Commands can then be executed using the ADOCommand's Execute method. TADOCommand is most often used for executing data definition language (DDL) SQL commands. The CommandText property specifies the command to execute. The CommandType property determines how the CommandText property is interpreted. The cmdText type is used to specify the DDL statement. Although it makes no sense to use the ADOCommand component to retrieve a dataset from a table, query, or stored procedure, you can do so.

منبع سایت delphi.about.com



ADOCommand
The ADOCommand component encapsulates an ADO command object, which can be used to execute SQL statements, including data definition language (DDL) statements such as CREATE TABLE or ALTER INDEX, as well as execute stored procedures that do not return a result set. If you are already familiar with the ADO command object, you will find that the ADOCommand component sports the same programming interface as that object.
One notable benefit of the ADOCommand object is that you can use it to return a Recordset (a pointer to one or more records from a data source). After executing an ADOCommand to return a Recordset, set an ADODataSet’s public Recordset property to the corresponding ADOCommand.


منبع

http://www.coadletter.com/article/borcon/files/6002/paper/6002.html

sasan_vm
سه شنبه 07 خرداد 1387, 19:11 عصر
سلام.تاجاییکه من اطلاع دارم اصلا Adocommand چیزی برای شما برنمی گردونه.شما میتونی از adodataset استفاده کنی.adocommand فقط برای execute کردن دستورات به کار میره.

تابع execute در Adocommand بسته به نوع دستوری که مینویسی میتونه نتیجه یک procedure یا یک فرمان رو برگردونه.

در مثالی که اوردم sp_helpdb یک system procedure هست که بسته به پارامتر ورودی یک recordset یا دو recordset را بر می گرداند. دستورات T-SQL را با توابع Execute باید اجرا کرد
AdoCommadn, AdoConnection . هرچند دستور select را هم می شود با AdoCommand
اجرا کرد.


R : _RecordSet;
...
..
.
R := ADOCommand1.Execute('select * from [MyTable]');
R.MoveFirst;
while NOT R.EOF do
{ Do any thing with selected filed }
begin

vcldeveloper
سه شنبه 07 خرداد 1387, 19:50 عصر
من ندیدم که مجموعه کامپوننت های ADO در دلفی امکان دریافت بیش از یک Recordset را داشته باشند، ولی دیدم که SDAC همچین امکانی داره.

sasan_vm
چهارشنبه 08 خرداد 1387, 16:51 عصر
من ندیدم که مجموعه کامپوننت های ADO در دلفی امکان دریافت بیش از یک Recordset را داشته باشند، ولی دیدم که SDAC همچین امکانی داره.

هر جا به بن بست میرسیم آخرش SDAC مطرح میشه :لبخند:

vcldeveloper
چهارشنبه 08 خرداد 1387, 19:22 عصر
هر جا به بن بست میرسیم آخرش SDAC مطرح میشه
در استفاده ازش شک نکنید.