Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

DataTableAdapter

Back to Forum: Tech Off
  • User profile image
    Frisky

    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?

    Thanks,

    Frisky

  • 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

       ...


       trans.Complete();

    }

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

    Hope this helps. Smiley
    Gary Cox

  • User profile image
    Frisky

    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.

    Frisky

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.