From: Matt H. <ma...@xp...> - 2004-01-21 16:24:45
|
I've been working on a custom Data Adapter for the last day. It uses FbDataAdapter to perform some operations, but it implements an Update() method that works correctly with stored procedures. It can take either a DataSet or DataTable as input. If called with a DataSet, it calls the custom Update method with each DataTable within the DataSet. For each row in a table, the Update method checks it to see if it has been deleted, modified, or added. It then calls the appropriate method to handle each case. For example, if a row has been deleted, it calls DoDelete with the row that needs to be deleted. This method then checks for the existence of a FbCommand object for doing deletes. It loads the command's input parameters from the source row, then executes the command. The method then checks for the existence of an output parameter named "SUCCESS". If its there, then the method checks to see if SUCCESS is 1. If so, it returns a value indicating that the operation was successful. If SUCCESS is 0, it returns a value indicating that the operation failed. Otherwise, it assumes that the operation was successful and returns a value indicating success. This is a bit of a hack, but it's the only way I could come up with to determine whether or not the stored procedure affected any rows. This requires that the stored procedure check for success (in the case of the stored procedure for the delete command, it checks to make sure the target row exists, sets the output parameter SUCCESS to 1 if does, then performs the delete). There is more logic in the custom adapter than I've described (basic initialization and cleanup mainly), but I think that describes the important pieces. I would like to see FbDataAdapter fixed so that it works with FbCommand objects that are stored procedures, but it may be that this isn't doable without some modifications to the Firebird database itself. If anyone has any questions or suggestions, please feel free to contact me. ---Matt |