Tech Off Thread

3 posts


Back to Forum: Tech Off
  • User profile image

    We are using the .Net 2.0 Autogenerated DataTableAdapter, etc.

    However, I need to change the connection string when executing. Does anyone know how to do this? If so, how?

    Also, there may be a need to supply a transaction object. Can this be done? If so, how?



  • User profile image
    Gary Cox

    It sounds like your using a BindingSource, if so, it gets its connection string from Properties.Settings.Default.YourConnectionStringName, you can change this at runtime.  Microsoft introduced the System.Transactions class.  You can use this to handle your transaction needs.

    using (TransactionScope trans = new TransactionScope(TransactionScopeOption.Required))
       // Do your database updates




    If anything fails within the block then all database updates are rolled back.

    Hope this helps. Smiley
    Gary Cox

  • User profile image

    Thanks for the response.

    Well, yes it does get the property from global::Properties.Settings.Default.MyConnection, however, the property is read-only. I do see some other functionality there, such as a Propteries and PropertyValues collection that are a member of this item. So, maybe you can change it through some other method. But, in the 5 minutes I have had to look at it, I did not find it.

    I will be looking at the Transaction piece tomorrow.

    Thanks for the information.


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.