The Kinetic Jump site navigation header requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

Welcome Guest Search | Active Topics | Log In | Register

Transacted Database Actions Options
adamh
#1 Posted : Thursday, August 09, 2007 11:13:59 AM
Rank: Administration
Groups: Member, Administration

Joined: 7/12/2007
Posts: 17
Location: Michigan
Here is a useful custom action example. This example came from a question about how to transact multiple database calls during an update. To accomplish this, you can place a transaction object in the update context shared properties collection. I created these custom actions to perform database work in an update process. They use the Provider Independent Model for data access and should be quite useful as they are, but the source code for these actions is also attached.

The Actions:
Begin Database Transaction
Represents an action that opens a connection to a database, begins a transaction, and stores both the transaction and a DbProviderFactory that can be used to create objects to work with the database in other actions. You can reference the DbProviderFactory by using the transaction object itself as the SharedProperties key. In the event of an error in the update execution, this action will roll back its transaction in the update rollback stage.

Configuration
Connection String: You can set the connection string directly in the property grid, or you can provide a config file name and connection string key name from the configuration connection strings collection. You need to do one or the other.
Data Provider: You can set the data provider directly or you can provide a Data Provider Setting Name and retrieve it from the appSettings collection of the defined config file as well. You need to do one or the other. The Data Provider specifies the specific data classes to use, for example: System.Data.SqlClient or System.Data.OleDb. The data provider must be installed on the client’s system.
Isolation Level: Pick the transaction’s isolation level from the drop down.
Transaction Key: Provide a name for this transaction. You will need to enter this on the other actions so that they reference the same transaction.


Transacted Stored Procedure
Represents an action to execute a stored procedure in a database transaction. You would use this action to initiate a stored procedure in the database on a designated transaction.

Configuration
Stored Procedure Name: Provide the name of the stored procedure to execute.
Transaction Key: Provide the name given to the Begin Database Transaction action that must precede this action in the action list.
Parameters: Provide the parameters needed by the stored procedure. Each parameter has the following properties:

  • Direction: The parameter’s direction: Input, Output, or InputOutput. The action does not provide any means of processing output parameters.
  • IsNull: Set this property to True to force the parameter’s value to be null. Setting it to False resets the parameter to its default value. This property is also automatically set to False if a different value is specified for the parameter.
  • Name: The name of the parameter.
  • Size: The size of the parameter’s data, if it has a fixed size.
  • Type: The data type of the parameter. Xml and Object values are stored as strings; other values as their corresponding .NET classes (Int32 as Int32, Date, Time, and DateTime as DateTime, Double as Double, etc.).
  • Value: The parameter’s value.


    Transacted Database Query
    Represents an action to execute a query in a database transaction. You would use this action to initiate an ad-hoc query on a designated transaction.

    Configuration
    Query Text: Enter the sql that should be executed on your database.
    Transaction Key: Provide the name given to the Begin Database Transaction action that must precede this action in the action list.

    Commit Database Transaction
    Represents an action to commit a transaction started by a BeginTransactionAction. This action should be the last action in your update action list. Once this action has been executed, the transaction can’t be rolled back.

    Configuration
    Transaction Key: Provide the name given to the Begin Database Transaction action that must precede this action in the action list.

    I have tested these actions on SQL Server, MSDE, and Access. I would like to hear feedback on other databases. Enjoy and happy coding.
    File Attachment(s):
    Kjs.AppLife.Update.DataActions.dll (37kb) downloaded 22 time(s).
    DbTransactionActionsSourceCode.zip (15kb) downloaded 24 time(s).
    Adam Hill
    Kinetic Jump Software
  • larspl
    #2 Posted : Monday, December 03, 2007 10:10:49 AM
    Rank: Newbie
    Groups: Member

    Joined: 11/3/2007
    Posts: 4
    Hello Support,

    pls provide some ScreenShots to Helpfile
    to see

    how u mean configuring a connection from a existing App.Config File.

    Sincerely

    Lars
    brianh
    #3 Posted : Monday, December 03, 2007 11:08:41 AM
    Rank: Administration
    Groups: Member, Administration

    Joined: 5/24/2007
    Posts: 362
    Location: Minnesota

    Hello Lars,

     

    These database actions were added to the AppLife Update product in version 1.1.  

     

    The built in actions have more untuitive editors that you can use to configure them.

     

    I would only recommend using these custom actions if you want to extend the source code.

     

    You can configure the built in actions to use a config file by using either the <appSettings> section or the <connectionStrings> section.  This is set by the Connection string property.

     

    Then you must define which config file to use by setting the location and file name.

     

    The attached screen shot properly configures a connection string from a config file that is located in the same directory as the hosting application executable and is named example.exe.config.  The connection string to use is named sqlConnection.

     

    config snippet

    <connectionStrings>

      <add name="theConnection" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data   Source=C:\...\UpdateTests\DbActions.mdb;Persist Security Info=True"

    providerName="System.Data.OleDb" />

      <add name="sqlConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\...\UpdateTests\Database2.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

    providerName="System.Data.SqlClient" />

    </connectionStrings>

     

     

     

     

    brianh attached the following image(s):
    config file setup.jpg
    Brian Haas
    Kinetic Jump Software
    Users browsing this topic
    Guest
    You cannot post new topics in this forum.
    You cannot reply to topics in this forum.
    You cannot delete your posts in this forum.
    You cannot edit your posts in this forum.
    You cannot create polls in this forum.
    You cannot vote in polls in this forum.