• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1344
  • Last Modified:

Help overriding tableadapter connection string in c#

I am trying to override the default connection string in a table adapter with a string that gets built using the connectionstringbuilder

            SqlConnection c = ConnStrBuilder.BuildConnection(orgid);
            tvEventLocationsPlusNamesTableAdapter tvELNByEventAdapt = new tvEventLocationsPlusNamesTableAdapter();
            tvELNByEventAdapt.Connection = c;

This little snippet is what my current code is but it returns an error because the tvELNByEventAdapt doesnt contain a definition for 'Connection'.

What is  the correct way for me to override the default connection string for the table adapter so that its using the correct connection string?

  • 2
1 Solution
Gautham JanardhanCommented:
i think u will have to do

tvELNByEventAdapt.SelectCommand.Connection = c;

si,ilarly for inserte, update and delete commands
PryssonAuthor Commented:
THat just gives me the same error about not containing a definition.

PryssonAuthor Commented:
Never mind the problem was that the adapter was hosed. I recreated teh adapter and my code works fine now.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now