The ConnectionString property has not been initialized.

  • Thread starter Thread starter rlm
  • Start date Start date
R

rlm

I am using TableAdapters the same way in the code below. The first works, and
the second does not. Names shortened here for simplicity, and values
hardcoded.
In both cases I can stop in the debugger and see the correct connection
string in the TableAdapter, which they both get from web.config. I can't see
any difference between the two which would indicate why the second one fails.
Ideas?

XTableAdapter ta = new XTableAdapter();
if (ta.MarkAsDeleted(40) == 1) {//delete ok- now delete children
YTableAdapter taContact = new YTableAdapter();
if (taContact.MarkAsDeleted(72) == 1) {
Console.WriteLine("OK");
}
}

Also, I started getting a message box whenever I leave the VS DataSet
designer GUI which says "Connection string not set - cannot get data design
context". It has no further info. I have looked at every adapter and they all
have a connection string specified.
 
Do not know the root cause.
Fix. Remove all tables from the dataset designer which have in their
InitCommandCollection[see designer.cs] the Connection set to Connection = new
global::System.Data.SqlClient.SqlConnection(""); instead of this.Connection;

Removing one table at a time did not fixt the problem. All of them had to be
removed and then added back in one at a time, with each query manually
readded. This eliminated both errors.
 
Back
Top