传送参数方法
procedure Database.PrepareCommand(command: SqlCommand; connection: SqlConnection; transaction: SqlTransaction; commandType: CommandType; commandText: string; commandParameters: SqlParameter[]; [Out] var mustCloseConnection: boolean);
begin
if (command = nil) then
raise ArgumentNullException.Create('command');
if ((commandText = nil) or (commandText.Length = 0)) then
raise ArgumentNullException.Create('commandText');
if (connection.State <> ConnectionState.Open) then
begin
mustCloseConnection := true;
connection.Open
end
else
mustCloseConnection := false;
command.Connection := connection;
command.CommandText := commandText;
if (transaction <> nil) then
begin
if (transaction.Connection = nil) then
raise ArgumentException.Create('The transaction was rollbacked or commited, please provide an open transaction.', 'transaction');
command.Transaction := transaction
end;
command.CommandType := commandType;
if (commandParameters <> nil) then
Database.AttachParameters(command, commandParameters)
end;