Torna al Thread

[CODE]Dim DS As New Data.DataSet Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Quando carica il programma deve verificare l'esistenza o meno 'del file XML che contiene il registro degli eventi Dim EsistenzaRegistro As Boolean EsistenzaRegistro = My.Computer.FileSystem.FileExists(Application.StartupPath + "\RegistroCode.xml") 'Se il file non esiste allora crea un file XML con la relativa struttura 'dichiarata che fungerà da database If EsistenzaRegistro = False Then DS.DataSetName = "DatasetCodice" DS.Tables.Add("RegistroCodice") DS.Tables("RegistroCodice").Columns.Add("Nome") DS.Tables("RegistroCodice").Columns.Add("Cognome") DS.WriteXml(Application.StartupPath + "\RegistroCode.xml", XmlWriteMode.WriteSchema) End If DS.ReadXml(Application.StartupPath + "\RegistroCode.xml") DG.DataSource = DS DG.DataMember = "RegistroCodice" End Sub Private Sub salva_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles salva.Click Dim nuovomodulo As DataRow = DS.Tables("RegistroCodice").NewRow nuovomodulo("Nome") = Me.cmpnome.Text nuovomodulo("Cognome") = Me.cmpcognome.Text DS.Tables("RegistroCodice").Rows.Add(nuovomodulo) DS.WriteXml(Application.StartupPath + "\RegistroCode.xml") End Sub[/CODE]
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5