Code disappearing from InitializeComponent in VS 2003

W

Winshent

I have read many threads which indicate that this was a problem with
version 2002. Why should i be suffering this?

I am using VB.NET 2003 Standard Edition...

is it still a problem with 2003?

I have used the wizards to generate the connection and adapter, which
generates the code in 'InitializeComponent', and i have stored the
connection string within web.config and it seems to get rid of this
every so often.

Is there a quick work around or patch?
 
J

Jim Cheshire [MSFT]

Hi Winshent,

Are you manually adding any code to InitializeComponent? What code exactly
is being removed?

There is a bug that can cause this code to be removed when you change the
EnableViewState property. If that's what is happening to you, you need to
call in to us so that we can deliver that hotfix to you. Please, I don't
want to see a barrage of people e-mailing me directly asking for the fix!
:) You need to call us so that we can track who gets it.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
 
W

Winshent P

Is there a UK support number? or do i need to call you directly?

If so then email me your number.

Thanks

Vincent..

PS.. i have removed the code from InitializeComponent which has now got
round the problem.
 
J

Jim Cheshire [MSFT]

Winshent,

First of all, you didn't answer my question! :) Did you manually add code
to the InitializeComponent method? It seems to me that you are saying that
you did. If so, therein lies your problem. You should not directly modify
that code. If you do, your code will be modified. That's why we place the
large comment block warning you not to modify it.

If you didn't add code manually, you can call your local office to get the
hotfix. You can find a number at http://support.microsoft.com.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
 
W

Winshent P

Jim

The only code i added was (which disappeared every so often):
(System.Configuration.ConfigurationSettings.AppSettings.Get("ConnectionS
tring"))

on the end of:
Me.WizConnection = New System.Data.SqlClient.SqlConnection

occasionally the complete line would disappear..



Here is the code which was generated after using the Adapter and
Connection wizards:

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.WizDataAdapter = New System.Data.SqlClient.SqlDataAdapter
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.WizConnection = New
System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationSe
ttings.AppSettings.Get("ConnectionString"))
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
'
'WizDataAdapter
'
Me.WizDataAdapter.InsertCommand = Me.SqlInsertCommand1
Me.WizDataAdapter.SelectCommand = Me.SqlSelectCommand1
Me.WizDataAdapter.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "tblResults", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("ID", "ID"), New
System.Data.Common.DataColumnMapping("Line", "Line"), New
System.Data.Common.DataColumnMapping("LogDate", "LogDate"), New
System.Data.Common.DataColumnMapping("IneffExclEngaged",
"IneffExclEngaged"), New System.Data.Common.DataColumnMapping("Engaged",
"Engaged"), New System.Data.Common.DataColumnMapping("Offered",
"Offered"), New System.Data.Common.DataColumnMapping("Answered",
"Answered"), New System.Data.Common.DataColumnMapping("Answered30s",
"Answered30s"), New System.Data.Common.DataColumnMapping("Abandoned",
"Abandoned"), New System.Data.Common.DataColumnMapping("Abandoned30s",
"Abandoned30s"), New
System.Data.Common.DataColumnMapping("ServiceLevelRatio",
"ServiceLevelRatio"), New
System.Data.Common.DataColumnMapping("IneffectiveRatio",
"IneffectiveRatio"), New
System.Data.Common.DataColumnMapping("EngagedRatio", "EngagedRatio"),
New System.Data.Common.DataColumnMapping("AbandonedRatio",
"AbandonedRatio")})})
'
'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "INSERT INTO tblResults(ID, Line,
LogDate, IneffExclEngaged, Engaged, Offered, Ans" & _
"wered, Answered30s, Abandoned, Abandoned30s, ServiceLevelRatio,
IneffectiveRatio" & _
", EngagedRatio, AbandonedRatio) VALUES (@ID, @Line, @LogDate,
@IneffExclEngaged," & _
" @Engaged, @Offered, @Answered, @Answered30s, @Abandoned,
@Abandoned30s, @Servic" & _
"eLevelRatio, @IneffectiveRatio, @EngagedRatio, @AbandonedRatio);
SELECT ID, Line" & _
", LogDate, IneffExclEngaged, Engaged, Offered, Answered,
Answered30s, Abandoned," & _
" Abandoned30s, ServiceLevelRatio, IneffectiveRatio, EngagedRatio,
AbandonedRatio" & _
" FROM tblResults"
Me.SqlInsertCommand1.Connection = Me.WizConnection
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@ID", System.Data.SqlDbType.Int, 4,
"ID"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Line",
System.Data.SqlDbType.VarChar, 100, "Line"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@LogDate",
System.Data.SqlDbType.DateTime, 8, "LogDate"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@IneffExclEngaged",
System.Data.SqlDbType.Int, 4, "IneffExclEngaged"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Engaged",
System.Data.SqlDbType.Int, 4, "Engaged"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Offered",
System.Data.SqlDbType.Int, 4, "Offered"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Answered",
System.Data.SqlDbType.Int, 4, "Answered"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Answered30s",
System.Data.SqlDbType.Int, 4, "Answered30s"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Abandoned",
System.Data.SqlDbType.Int, 4, "Abandoned"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Abandoned30s",
System.Data.SqlDbType.Int, 4, "Abandoned30s"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@ServiceLevelRatio",
System.Data.SqlDbType.Int, 4, "ServiceLevelRatio"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@IneffectiveRatio",
System.Data.SqlDbType.Int, 4, "IneffectiveRatio"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@EngagedRatio",
System.Data.SqlDbType.Int, 4, "EngagedRatio"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@AbandonedRatio",
System.Data.SqlDbType.Int, 4, "AbandonedRatio"))
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT ID, Line, LogDate,
IneffExclEngaged, Engaged, Offered, Answered, Answered3" & _
"0s, Abandoned, Abandoned30s, ServiceLevelRatio, IneffectiveRatio,
EngagedRatio, " & _
"AbandonedRatio FROM tblResults"
Me.SqlSelectCommand1.Connection = Me.WizConnection

End Sub
Protected WithEvents lbl7 As System.Web.UI.WebControls.Label
Protected WithEvents cmdUpdate As System.Web.UI.WebControls.Button
Protected WithEvents cmdEdit As System.Web.UI.WebControls.Button
Protected WithEvents cmdPrevious As System.Web.UI.WebControls.Button
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents txtC7 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtB7 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtA7 As System.Web.UI.WebControls.TextBox
Protected WithEvents lbl5 As System.Web.UI.WebControls.Label
Protected WithEvents lbl4 As System.Web.UI.WebControls.Label
Protected WithEvents lbl6 As System.Web.UI.WebControls.Label
Protected WithEvents lbl1 As System.Web.UI.WebControls.Label
Protected WithEvents lbl3 As System.Web.UI.WebControls.Label
Protected WithEvents lbl2 As System.Web.UI.WebControls.Label
Protected WithEvents txtA1 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtC6 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtA6 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtB6 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtC5 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtB5 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtA5 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtB4 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtC2 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtB2 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtA3 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtA2 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtC4 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtC3 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtC1 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtB3 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtA4 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtB1 As System.Web.UI.WebControls.TextBox
Protected WithEvents cmdNext As System.Web.UI.WebControls.Button


Protected WithEvents WizDataAdapter As
System.Data.SqlClient.SqlDataAdapter
Protected WithEvents SqlSelectCommand1 As
System.Data.SqlClient.SqlCommand
Protected WithEvents SqlInsertCommand1 As
System.Data.SqlClient.SqlCommand
Protected WithEvents WizConnection As
System.Data.SqlClient.SqlConnection
Protected WithEvents txtDate1 As System.Web.UI.WebControls.TextBox
Protected WithEvents txtDate2 As System.Web.UI.WebControls.TextBox
Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
 
T

Todd

Is this an issue that falls over in to other projects than just web? I seem
to be having some property values disappearing in my InitializeComponent
method as well. This is for a windows project. First a bunch of data
bindings were being lost, and then the same property on all of one type of
control were lost and I had to go back and manually reset them.

Any ideas?

Jim Cheshire said:
Winshent,

First of all, you didn't answer my question! :) Did you manually add code
to the InitializeComponent method? It seems to me that you are saying that
you did. If so, therein lies your problem. You should not directly modify
that code. If you do, your code will be modified. That's why we place the
large comment block warning you not to modify it.

If you didn't add code manually, you can call your local office to get the
hotfix. You can find a number at http://support.microsoft.com.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: Winshent P <[email protected]>
References: <[email protected]>
X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
Subject: RE: Code disappearing from InitializeComponent in VS 2003
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Date: Wed, 28 Jul 2004 09:24:20 -0700
NNTP-Posting-Host: 67.41.129.85
Lines: 1
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet:251417
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Is there a UK support number? or do i need to call you directly?

If so then email me your number.

Thanks

Vincent..

PS.. i have removed the code from InitializeComponent which has now got
round the problem.
 
J

Jim Cheshire [MSFT]

Winshent,

Don't modify / add / delete code in InitializeComponent. Instead, use
OnInit.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
Microsoft Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top