By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,369 Members | 1,550 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,369 IT Pros & Developers. It's quick & easy.

VS Code Auto-erasing

P: n/a
Hi All:

I am having a problem with visual studio automatically erasing my code. I
thought it was a fluke at first, but it KEEPS HAPPENING. I have a string
variable for a data connection that I do not assign a value until the
application loads (Reason: I do not know where my users are going to install
their applications, so it does it dynamically). This value is put into the
region of the Windows Form Designer generated code.

Problem is, that everytime that I modify a form after this code is put in.
The oledbconnection connection string disappears. All the other code
remains, but if put the code back and modify the form latter the connection
string disappears again. Okay, what do I do to fix this?

Rachel
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Simple answer is to remove the code from this area.
Anything you put in there will be wiped and rewritten automatically by the forms
designer.
You can place code after the InitializeComponent call in the Sub New.
Or you might try putting it into the Form Load Event or some more appropriate
place.

Gerald

"Rachel" <Ra****@discussions.microsoft.com> wrote in message
news:D9**********************************@microsof t.com...
Hi All:

I am having a problem with visual studio automatically erasing my code. I
thought it was a fluke at first, but it KEEPS HAPPENING. I have a string
variable for a data connection that I do not assign a value until the
application loads (Reason: I do not know where my users are going to install
their applications, so it does it dynamically). This value is put into the
region of the Windows Form Designer generated code.

Problem is, that everytime that I modify a form after this code is put in.
The oledbconnection connection string disappears. All the other code
remains, but if put the code back and modify the form latter the connection
string disappears again. Okay, what do I do to fix this?

Rachel

Nov 21 '05 #2

P: n/a
On Wed, 11 Aug 2004 12:01:06 -0700, Rachel wrote:
remains, but if put the code back and modify the form latter the connection
string disappears again. Okay, what do I do to fix this?


Where in the windows generated code are you placing your string? That
section can be regenerated when the form is change, hence the warning at
the top. If you place your string *after* the call to InitializeComponent,
it should not be removed when the code is regenerated.

The best solution would be to add an application configuration file to your
project and put your connectection string there.
--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.