Creating a Transaction object using drag and drop

In Visual Studio, you can create a Transaction object by dragging the Transaction item from the Sybase DataWindow 2.5 tab in the Toolbox to a form. Because it is a nonvisual object, its icon displays in the area below the form in a Windows application. In a Web site application, you need to open the Code Designer view to see the Transaction icon in the Toolbox and drag it to the view. You can right-click on the icon and display the Properties window to set properties, or you can set them in code.

If you use drag-and-drop to add the Transaction object to a form, the Transaction object is added to the form's components list. Objects on the components list are disposed automatically when the form is disposed, so you do not need to explicitly disconnect the transaction. However, if you declare the Transaction object in code, as described next, you must call the Disconnect method explicitly. The connection that the Transaction object represents is not closed automatically when the Transaction object goes out of scope.