Showing confirmation message.http://forums.asp.net/t/1556654.aspx/1?Showing+confirmation+message+Tue, 11 May 2010 09:52:01 -040015566543828900http://forums.asp.net/p/1556654/3828900.aspx/1?Showing+confirmation+message+Showing confirmation message. <p>Hi,</p> <p>The following codes insert the Data inside the XML file using the <b><i>ADD NEW USER</i></b> Form. Now i want to display the confirmation message to the User's that the <i>Data has been Successfully added</i> or<i> Data not inserted </i>message. Also i want to know how to add <b>TRY</b>, <b>CATCH</b> and <b>FINALLY</b> method in this code. Pls edit my code and send me. ]</p> <p><b>CODE:</b></p> <p><pre class="prettyprint">Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click ' Create a DataSet with one table and three columns. Dim OriginalDataSet As New DataSet(&quot;myDataSet&quot;) OriginalDataSet.Namespace = &quot;NetFrameWork&quot; Dim myTable As New DataTable(&quot;myTable&quot;) Dim c1 As New DataColumn(&quot;AccNumber&quot;, Type.GetType(&quot;System.Int32&quot;)) 'c1.AutoIncrement = True Dim c2 As New DataColumn(&quot;Name&quot;, Type.GetType(&quot;System.String&quot;)) Dim c3 As New DataColumn(&quot;Balance$&quot;, Type.GetType(&quot;System.Double&quot;)) myTable.Columns.Add(c1) myTable.Columns.Add(c2) myTable.Columns.Add(c3) OriginalDataSet.Tables.Add(myTable) Dim newRow As DataRow newRow = myTable.NewRow() newRow(&quot;AccNumber&quot;) = txtAccNumber.Text.ToString() newRow(&quot;Name&quot;) = txtName.Text.ToString() newRow(&quot;Balance$&quot;) = txtBalance.Text.ToString() myTable.Rows.Add(newRow) OriginalDataSet.AcceptChanges() ' Write the schema and data to an XML file. Dim xmlFilename As String = &quot;C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Demo_aps\Demo_aps\myXmlDocument.xml&quot; ' Use WriteXml to write the document. OriginalDataSet.WriteXml(xmlFilename) ' Dispose of the original DataSet. OriginalDataSet.Dispose() End Sub</pre><br> <br> </p> 2010-05-11T06:18:25-04:003829047http://forums.asp.net/p/1556654/3829047.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p><pre class="prettyprint">Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Try ' Create a DataSet with one table and three columns. Dim OriginalDataSet As New DataSet(&quot;myDataSet&quot;) OriginalDataSet.Namespace = &quot;NetFrameWork&quot; Dim myTable As New DataTable(&quot;myTable&quot;) Dim c1 As New DataColumn(&quot;AccNumber&quot;, Type.GetType(&quot;System.Int32&quot;)) 'c1.AutoIncrement = True Dim c2 As New DataColumn(&quot;Name&quot;, Type.GetType(&quot;System.String&quot;)) Dim c3 As New DataColumn(&quot;Balance$&quot;, Type.GetType(&quot;System.Double&quot;)) myTable.Columns.Add(c1) myTable.Columns.Add(c2) myTable.Columns.Add(c3) OriginalDataSet.Tables.Add(myTable) Dim newRow As DataRow newRow = myTable.NewRow() newRow(&quot;AccNumber&quot;) = txtAccNumber.Text.ToString() newRow(&quot;Name&quot;) = txtName.Text.ToString() newRow(&quot;Balance$&quot;) = txtBalance.Text.ToString() myTable.Rows.Add(newRow) OriginalDataSet.AcceptChanges() ' Write the schema and data to an XML file. Dim xmlFilename As String = &quot;C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Demo_aps\Demo_aps\myXmlDocument.xml&quot; ' Use WriteXml to write the document. OriginalDataSet.WriteXml(xmlFilename) ' Dispose of the original DataSet. OriginalDataSet.Dispose() ClientScript.RegisterClientScriptBlock(GetType(Page), &quot;&quot;, &quot;alert('success');&quot;, True) Catch ex As Exception ClientScript.RegisterClientScriptBlock(GetType(Page), &quot;&quot;, &quot;alert('failure');&quot;, True) End Try End Sub</pre><br> <br> </p> 2010-05-11T07:40:47-04:003829062http://forums.asp.net/p/1556654/3829062.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>&nbsp;Hi follow code mentioned by <a href="http://forums.asp.net/members/rizwanparkar.aspx"> rizwanparkar</a>&nbsp;but in finally u should dispose (OriginalDataSet.Dispose())<br> </p> 2010-05-11T07:50:50-04:003829068http://forums.asp.net/p/1556654/3829068.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>Hi rizwanparker,</p> <p>It showed two error message. after i edited the code as you provided.<br> </p> <p><i>Name Clientscript is not declared</i></p> <p><i>T</i><i>ype page is not defined.</i></p> <p><br> </p> <p><br> </p> 2010-05-11T07:55:40-04:003829078http://forums.asp.net/p/1556654/3829078.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>Hi Vijaya.A</p> <p>Ya i did as u said that:&nbsp; OriginalDataSet.Dispose() inside the finally block.</p> <p>but it also showed me error: Name &quot;OriginalDataSet&quot; is not Declared.</p> <p>Pls can u help me..<br> </p> 2010-05-11T08:00:11-04:003829096http://forums.asp.net/p/1556654/3829096.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Utsavp</h4> <p>Hi Vijaya.A</p> <p>Ya i did as u said that:&nbsp; OriginalDataSet.Dispose() inside the finally block.</p> <p>but it also showed me error: Name &quot;OriginalDataSet&quot; is not Declared.</p> <p>Pls can u help me..<br> </p> <p></p> </blockquote> &nbsp; <p></p> <p>Hi declare &quot;OriginalDataSet&quot;&nbsp;above try </p> 2010-05-11T08:08:29-04:003829101http://forums.asp.net/p/1556654/3829101.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Utsavp</h4> <p>Hi rizwanparker,</p> <p>It showed two error message. after i edited the code as you provided.<br> </p> <p><i>Name Clientscript is not declared</i></p> <p><i>T</i><i>ype page is not defined.</i></p> <p><br> </p> <p><br> </p> <p></p> </blockquote> &nbsp; <p></p> <p>use page.clientscript....</p> <p></p> 2010-05-11T08:10:53-04:003829165http://forums.asp.net/p/1556654/3829165.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>Still it shows Page is Not declared</p> <p><br> </p> <p>View my code again.</p> <p><br> </p> <p><pre class="prettyprint">Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click ' Create a DataSet with one table and three columns. Dim OriginalDataSet As New DataSet(&quot;myDataSet&quot;) OriginalDataSet.Namespace = &quot;NetFrameWork&quot; Dim myTable As New DataTable(&quot;myTable&quot;) Dim c1 As New DataColumn(&quot;AccNumber&quot;, Type.GetType(&quot;System.Int32&quot;)) 'c1.AutoIncrement = True Dim c2 As New DataColumn(&quot;Name&quot;, Type.GetType(&quot;System.String&quot;)) Dim c3 As New DataColumn(&quot;Balance$&quot;, Type.GetType(&quot;System.Double&quot;)) myTable.Columns.Add(c1) myTable.Columns.Add(c2) myTable.Columns.Add(c3) OriginalDataSet.Tables.Add(myTable) Try Dim newRow As DataRow newRow = myTable.NewRow() newRow(&quot;AccNumber&quot;) = txtAccNumber.Text.ToString() newRow(&quot;Name&quot;) = txtName.Text.ToString() newRow(&quot;Balance$&quot;) = txtBalance.Text.ToString() myTable.Rows.Add(newRow) OriginalDataSet.AcceptChanges() ' Write the schema and data to an XML file. Dim xmlFilename As String = &quot;C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Demo_aps\Demo_aps\myXmlDocument.xml&quot; ' Use WriteXml to write the document. OriginalDataSet.WriteXml(xmlFilename) 'OriginalDataSet.Dispose() ' Dispose of the original DataSet. 'MessageBox.Show(&quot;Inserted Successfully&quot;) 'Me.Hide() Page.ClientScript.RegisterClientScriptBlock(GetType(Page), &quot;&quot;, &quot;alert('success');&quot;, True) Catch ex As Exception Page.ClientScript.RegisterClientScriptBlock(GetType(Page), &quot;&quot;, &quot;alert('failure');&quot;, True) Finally OriginalDataSet.Dispose() End Try</pre><br> <br> </p> 2010-05-11T08:36:45-04:003829190http://forums.asp.net/p/1556654/3829190.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>Hi it is not showing any error for me and working fine for me</p> <p>&nbsp;</p> 2010-05-11T08:46:41-04:003829210http://forums.asp.net/p/1556654/3829210.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>hi Please can u say me why i am getting error message:</p> <p>Name &quot;Page&quot; is not declared and</p> <p>Type &quot;Page&quot; is not declared.</p> <p><br> </p> <p>Am i missing any Library or Class that supports the <b>Page</b>.</p> <p><br> </p> <p><br> </p> 2010-05-11T08:55:42-04:003829218http://forums.asp.net/p/1556654/3829218.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>Hi r u using windows application or web application</p> <p>if ur using&nbsp;&nbsp;windows application use msgbox-- for displaying msg success</p> <p>if ur using web application import&nbsp;<font size="2">System.Web.UI</font></p> 2010-05-11T08:59:34-04:003829252http://forums.asp.net/p/1556654/3829252.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>I am just using windows application.</p> <p>Now how to use the MsgBox in such a Situation...&nbsp; Please reply..<br> </p> <p><br> </p> 2010-05-11T09:16:58-04:003829260http://forums.asp.net/p/1556654/3829260.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>Hi use this&nbsp;code</p> <p><font size="2"></p> <p>MsgBox(</font><font color="#800000" size="2"><font color="#800000" size="2">&quot;Your Message&quot;</font></font><font size="2">) instead of page.register.........</font></p> <p></p> 2010-05-11T09:21:29-04:003829279http://forums.asp.net/p/1556654/3829279.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>can u send me a code. Please give me a complete answer.</p> <p><br> </p> <p><br> </p> 2010-05-11T09:28:19-04:003829292http://forums.asp.net/p/1556654/3829292.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>Hi I just &nbsp;modified ur above code</p> <pre class="prettyprint">Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click ' Create a DataSet with one table and three columns. Dim OriginalDataSet As New DataSet(&quot;myDataSet&quot;) OriginalDataSet.Namespace = &quot;NetFrameWork&quot; Dim myTable As New DataTable(&quot;myTable&quot;) Dim c1 As New DataColumn(&quot;AccNumber&quot;, Type.GetType(&quot;System.Int32&quot;)) 'c1.AutoIncrement = True Dim c2 As New DataColumn(&quot;Name&quot;, Type.GetType(&quot;System.String&quot;)) Dim c3 As New DataColumn(&quot;Balance$&quot;, Type.GetType(&quot;System.Double&quot;)) myTable.Columns.Add(c1) myTable.Columns.Add(c2) myTable.Columns.Add(c3) OriginalDataSet.Tables.Add(myTable) Try Dim newRow As DataRow newRow = myTable.NewRow() newRow(&quot;AccNumber&quot;) = txtAccNumber.Text.ToString() newRow(&quot;Name&quot;) = txtName.Text.ToString() newRow(&quot;Balance$&quot;) = txtBalance.Text.ToString() myTable.Rows.Add(newRow) OriginalDataSet.AcceptChanges() ' Write the schema and data to an XML file. Dim xmlFilename As String = &quot;C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Demo_aps\Demo_aps\myXmlDocument.xml&quot; ' Use WriteXml to write the document. OriginalDataSet.WriteXml(xmlFilename) 'OriginalDataSet.Dispose() ' Dispose of the original DataSet. 'MessageBox.Show(&quot;Inserted Successfully&quot;) 'Me.Hide() MsgBox(&quot;Success) Catch ex As Exception MsgBox(&quot;Failure) Finally OriginalDataSet.Dispose() End Try</pre> <p><br> &nbsp;</p> 2010-05-11T09:31:45-04:003829303http://forums.asp.net/p/1556654/3829303.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>follow the code by vijaya mam..its perfect</p> 2010-05-11T09:36:58-04:003829310http://forums.asp.net/p/1556654/3829310.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>Ok thank u very Much. At last My Code looks like:</p> <p><br> </p> <p><pre class="prettyprint">Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click ' Create a DataSet with one table and three columns. Dim OriginalDataSet As New DataSet(&quot;myDataSet&quot;) OriginalDataSet.Namespace = &quot;NetFrameWork&quot; Dim myTable As New DataTable(&quot;myTable&quot;) Dim c1 As New DataColumn(&quot;AccNumber&quot;, Type.GetType(&quot;System.Int32&quot;)) 'c1.AutoIncrement = True Dim c2 As New DataColumn(&quot;Name&quot;, Type.GetType(&quot;System.String&quot;)) Dim c3 As New DataColumn(&quot;Balance$&quot;, Type.GetType(&quot;System.Double&quot;)) myTable.Columns.Add(c1) myTable.Columns.Add(c2) myTable.Columns.Add(c3) OriginalDataSet.Tables.Add(myTable) Try Dim newRow As DataRow newRow = myTable.NewRow() newRow(&quot;AccNumber&quot;) = txtAccNumber.Text.ToString() newRow(&quot;Name&quot;) = txtName.Text.ToString() newRow(&quot;Balance$&quot;) = txtBalance.Text.ToString() myTable.Rows.Add(newRow) OriginalDataSet.AcceptChanges() ' Write the schema and data to an XML file. Dim xmlFilename As String = &quot;C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Demo_aps\Demo_aps\myXmlDocument.xml&quot; ' Use WriteXml to write the document. OriginalDataSet.WriteXml(xmlFilename) 'OriginalDataSet.Dispose() ' Dispose of the original DataSet. 'MessageBox.Show(&quot;Inserted Successfully&quot;) 'Me.Hide() MsgBox(&quot;Data Inserted Successfully&quot;) Catch ex As Exception MsgBox(&quot;Field Missing: Unable to Insert Data.&quot;) Finally OriginalDataSet.Dispose() End Try End Sub</pre><br> <br> </p> <p><br> </p> 2010-05-11T09:40:48-04:003829335http://forums.asp.net/p/1556654/3829335.aspx/1?Re+Showing+confirmation+message+Re: Showing confirmation message. <p>Thank u very much. My code looks like this after error is free</p> <p><br> </p> <p><pre class="prettyprint">Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click ' Create a DataSet with one table and three columns. Dim OriginalDataSet As New DataSet(&quot;myDataSet&quot;) OriginalDataSet.Namespace = &quot;NetFrameWork&quot; Dim myTable As New DataTable(&quot;myTable&quot;) Dim c1 As New DataColumn(&quot;AccNumber&quot;, Type.GetType(&quot;System.Int32&quot;)) 'c1.AutoIncrement = True Dim c2 As New DataColumn(&quot;Name&quot;, Type.GetType(&quot;System.String&quot;)) Dim c3 As New DataColumn(&quot;Balance$&quot;, Type.GetType(&quot;System.Double&quot;)) myTable.Columns.Add(c1) myTable.Columns.Add(c2) myTable.Columns.Add(c3) OriginalDataSet.Tables.Add(myTable) Try Dim newRow As DataRow newRow = myTable.NewRow() newRow(&quot;AccNumber&quot;) = txtAccNumber.Text.ToString() newRow(&quot;Name&quot;) = txtName.Text.ToString() newRow(&quot;Balance$&quot;) = txtBalance.Text.ToString() myTable.Rows.Add(newRow) OriginalDataSet.AcceptChanges() ' Write the schema and data to an XML file. Dim xmlFilename As String = &quot;C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Demo_aps\Demo_aps\myXmlDocument.xml&quot; ' Use WriteXml to write the document. OriginalDataSet.WriteXml(xmlFilename) 'OriginalDataSet.Dispose() ' Dispose of the original DataSet. 'MessageBox.Show(&quot;Inserted Successfully&quot;) 'Me.Hide() MsgBox(&quot;Data Inserted Successfully&quot;) Catch ex As Exception MsgBox(&quot;Field Missing: Unable to Insert Data.&quot;) Finally OriginalDataSet.Dispose() End Try End Sub</pre><br> <br> </p> 2010-05-11T09:52:01-04:00