Changing the connection string of a QueriesTableAdapter at Runtime

Hi Guys,

Is it possible to change the connection string of a QueriesTableAdapter at Runtime

I figured out how to change the connection string of a normal table adapter by changing the ConnectionModifier to public but the QueriesTableAdapter doesn't seem to have this option.

Any ideas

Thanks
Woody


Answer this question

Changing the connection string of a QueriesTableAdapter at Runtime

  • Namfon

    Hello Woody

       You can add this as a seperate class file . Add a new class file thru Add->New item(Class.vb) dialog . TableAdapters are in a different namespace . You can just add the code from my previous post . 

    Hope this helps .

    Thanks

    Sunder

    vb.net


  • Randy Shoopman

    Hello Woody

        You can write a partial class and you can access the commands connection properties from that class . You can call that method before you fill . Code will be similar to this

    Namespace DataSet1TableAdapters

    Partial Class QueriesTableAdapter

    Public Sub changeConnection()

    Me.CommandCollection(0).Connection = "" ' Change the connection here

     

    End Sub

    End Class

    End Namespace

     

    Thanks

    Sunder

    vb.net


  • sun21170

    I can't seem to get that to work.

    How do I implement this partial classs

    I double clicked the .xsd file in the solution explorer which opened up the display with my QueriesTableAdapter in.

    I then double clicked the QueriesTableAdapter and got a simple partial class but of the dataset not of the queriestableadapter.

    Manually putting the code in doesn't work either as 'me' only has 'changeconnection' as it's only method.

    Thanks
    Woody




  • Changing the connection string of a QueriesTableAdapter at Runtime