Skip to content

Changing Table Adapter Connection string through code

roy roy

Asked Jan 13, 2008, 5:59 PM EST1 answer
Share
LinkedInX

I appreciate you help.

I am trying to set(change) the connection string of a data adapter through code.
For that , I created another partial class, and tried to override the this._connection property.

 

public override void InitConnection()

        {

            this._connection = new System.Data.SqlClient.SqlConnection();

            this._connection.ConnectionString = ”my new connection string”

        }

I keep on getting error:  “ 'HelperUtils.Dal.dsUtilsTableAdapters.tableAdapterlUTILS_Params' already defines a member called 'InitConnection' with the same parameter types   “

 

If I’m using the method without the “override” keyword, it reports an error :
” Type 'HelperUtils.Dal.dsUtilsTableAdapters.tableAdapterlUTILS_Params' already defines a member called 'InitConnection' with the same parameter types”.

 

What method can I call?  How?

Thanks a lot Roy

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi -

    It looks like your post is a few months old, but I had the same problem and this was what I needed:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1949769&SiteID=1

    I followed that advice and set the ConnectionModifier to public, then before I called the Fill() method on my TableAdapter, I created a new connection (with a different connection string) and assigned it to the TableAdapter.
    0