Setting the Connection String for a TableAdapter

1. Open the DataSet designer (XSD file)

2. Select each table adapter of interest, and in the Properties Window set the ConnectionModifier property to Public.

Image

3. Wherever in code you need to set the connection string, do the following.

Dim ta as FoobarTableAdapters.FoobarTableAdapter
Dim conn as SqlConnection = New SqlConnection(connectionString)
conn.Open()
ta.Connection = conn