none
All TableAdapters managed by a TableAdapterManager must use the same connection string. RRS feed

  • Question

  • Gentle reader,
    this my today's issue with Visual Studio 2008 and C# .

    I created a typed dataset with 15 tables in it, and it was automatically generated a namespace with TablesAdapter definitions.
    Good.
    All table adapters takes the connection string from Properties.Settings.Default.ConnectionString of the project.
    Great.
    But,
    when I update a dataset through a system generated TableAdapterManager I receive this exception:
    "All TableAdapters managed by a TableAdapterManager must use the same connection string."

    Going deep in that I found that within the code in the UpdateAll method, T.A.M. compares its connection string with every existing Table Adapter linked (with method MatchTableAdapterConnection).

    Info about my connection string are the following:
    Initial Catalog = Catalog
    User ID = MyID
    Password = MyPassword


    Well, this is what I found inside UpdateAll() method:
    this.Connection.ConnectionString = "Data Source=DELTA3\\SQLEXPRESS;Initial Catalog=Catalog;User ID=MyID;"
    _table1tableadapter.Connection.ConnectionString = "Data Source=DELTA3\\SQLEXPRESS;Initial Catalog=Catalog;User ID=MyID;"
    _table2tableadapter.Connection.ConnectionString = "Data Source=DELTA3\\SQLEXPRESS;Initial Catalog=Catalog;User ID=MyID;"
    _table3tableadapter.Connection.ConnectionString = "Data Source=DELTA3\\SQLEXPRESS;Initial Catalog=Catalog;User ID=MyID;"
    _table4tableadapter.Connection.ConnectionString = "Data Source=DELTA3\\SQLEXPRESS;Initial Catalog=Catalog;User ID=MyID;Password=MyPassword"

    So, connection string of TAM, table adapter 1, 2 and 3 are equals. Table Adapter 4th is different.
    But, guess what?

    Properties.Settings.Default.ConnectionString is like 4th, so "Data Source=DELTA3\\SQLEXPRESS;Initial Catalog=Catalog;User ID=MyID;Password=MyPassword".
    Why?

    Please help me.

    ------- Life is what happens while doing other projects -------
    Saturday, June 13, 2009 3:49 PM

Answers

  • I found the solution.
    Must change the connection string as following:

    Persist Security Info=True;Data Source=MYSERVER\\MYINSTANCE;Initial Catalog=MyCatalog;User ID=MyUserID;Password=MyPassword

    Taken from MSDN Library
    The Persist Security Info property specifies whether the data source can persist sensitive authentication information such as a password.+

     Security Note:
    The default setting for the Persist Security Info keyword is false. Setting it to true or yes allows security-sensitive information, including the user ID and password, to be obtained from the connection after the connection has been opened. Keep PersistSecurity Info set to false to ensure that an untrusted source does not have access to sensitive connection string information.

    I will start another thread to understand next step.


    ------- Life is what happens while doing other projects -------
    Monday, June 15, 2009 3:59 PM

All replies

  • I want to add something to my experience with this problem:
    i saw that the command responsible for changing the Connection string is one tableadapter.FillByProperty method.

    So, this is my new situation:
    BEFORE:
    TableAdapterX has a connection string with password in it.

    I launch a FillBy method which populates a table.

    THEN:
    TableAdapterX has a different connection string without password.

    If you can explain me this, it would be enough to understand.
    After a single tableadapter connection string changing, it is acceptable that the table adapter manager changes its c.s.

    Hope you can help me.


    ------- Life is what happens while doing other projects -------
    Sunday, June 14, 2009 2:55 PM
  • I found the solution.
    Must change the connection string as following:

    Persist Security Info=True;Data Source=MYSERVER\\MYINSTANCE;Initial Catalog=MyCatalog;User ID=MyUserID;Password=MyPassword

    Taken from MSDN Library
    The Persist Security Info property specifies whether the data source can persist sensitive authentication information such as a password.+

     Security Note:
    The default setting for the Persist Security Info keyword is false. Setting it to true or yes allows security-sensitive information, including the user ID and password, to be obtained from the connection after the connection has been opened. Keep PersistSecurity Info set to false to ensure that an untrusted source does not have access to sensitive connection string information.

    I will start another thread to understand next step.


    ------- Life is what happens while doing other projects -------
    Monday, June 15, 2009 3:59 PM
  • I have seen this too, if you have more than one adapter for a table, you need to set each of them properly before executing any commands.

    You can do something like below in the ds designer, but I dont think thats the perfect solution.

     

    Partial Public Class SomeTableAdapter

     

    Public Property SqlConnection() As System.Data.SqlClient.SqlConnection

     

    Get

     

    Return CType(Me.CommandCollection(0).Connection, SqlClient.SqlConnection)

     

    End Get

     

    Set(ByVal value As System.Data.SqlClient.SqlConnection)

     

    Me.CommandCollection(0).Connection = value

     

    End Set

     

    End Property

    Tuesday, July 14, 2009 3:25 AM
  • This was a GREAT help!

    Thank you very much.

    Wednesday, August 11, 2010 8:10 AM
  • Thanks a lot man... this trick worked like a charms.

     

    Regards,

     

    Mujtaba Panjwani

     

    Saturday, February 5, 2011 10:36 PM
  • Hi, this is a great tip - it solved the issue I had been experiencing for over 1 day without a solution.  The exact answer, when searching on the exact error message.

    Much appreciated.

    Geoff

    Tuesday, March 22, 2011 12:54 PM

  • I found the solution.
    Must change the connection string as following:

    Persist Security Info=True;Data Source=MYSERVER\\MYINSTANCE;Initial Catalog=MyCatalog;User ID=MyUserID;Password=MyPassword

    Taken from MSDN Library
    The Persist Security Info property specifies whether the data source can persist sensitive authentication information such as a password.+

     Security Note:
    The default setting for the Persist Security Info keyword is false. Setting it to true or yes allows security-sensitive information, including the user ID and password, to be obtained from the connection after the connection has been opened. Keep PersistSecurity Info set to false to ensure that an untrusted source does not have access to sensitive connection string information.

    I will start another thread to understand next step.


    ------- Life is what happens while doing other projects -------

    Thank you very much for that solution

    I spent hours and hours trying to solve this problem but i failed, once i implemented your solution it works great

    Again thanks alot

    Tarik

    Friday, May 27, 2011 7:46 PM
  • Thanks a lot for posting this.

    It saved me a TON of time I'm sure.

    Sunday, September 25, 2011 4:55 AM