Classe connectionString

mercoledì 09 aprile 2014 - 21.48
Tag Elenco Tags  VB.NET  |  .NET 4.0  |  Visual Studio 2010

Mau67 Profilo | Expert

Un saluto al forum,
volevo chiedervi come posso far dentro un modulo alcune impostazioni salvate in un file tramire dataset?

posto il codice che uso per salvare le impostazioni nel file e caricarle nelle textbox
Private ConfigPathname As String = Application.ExecutablePath + ".Settings"

Private Sub butnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butnSave.Click
Dim xDS As New Settings
Dim xRow As Settings.MainRow
xRow = xDS.Main.NewMainRow
xRow.Username = textUsername.Text.Trim()
xRow.PIN = Int32.Parse(textPIN.Text.Trim())
xRow.Admin = chckAdmin.Checked
xDS.Main.AddMainRow(xRow)
xDS.WriteXml(ConfigPathname, System.Data.XmlWriteMode.IgnoreSchema)
End Sub

Private Sub butnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butnLoad.Click
If New FileInfo(ConfigPathname).Exists Then
Dim xDS As New Settings
Dim xRow As Settings.MainRow
xDS.ReadXml(ConfigPathname, System.Data.XmlReadMode.IgnoreSchema)
If xDS.Main.Rows.Count > 0 Then
xRow = xDS.Main.Rows.Item(0)
If Not xRow.IsUsernameNull() Then
textUsername.Text = xRow.Username
End If
If Not xRow.IsPINNull() Then
textPIN.Text = xRow.PIN.ToString()
End If
If Not xRow.IsAdminNull() Then
chckAdmin.Checked = xRow.Admin
End If
End If
End If
End Sub

io vorrei che invece di caricarle nelle textbox dentro il form vorrei passarle al modulo e renderle disponibili per tutto il progetto

Public Shared Function Getimpostazioni() As String
Return "username=" & username & ";" & _
"pin=" & xRow.PIN.ToString() & ";" & _
"admin=" & xRow.Admin
End Function

come posso fare?
grazie
Mau67

ridaria Profilo | Expert

devi mettere i valori in variabili di tipo public dichiarate possibilmente in un modulo di classe *.vb ove vai a mettere tutte le variabili pubbliche del progetto.


La var publica è questa:

Public ID_CLIENTE As Long = 0


ciao

fammi sapere


Riccardo D'Aria

Mau67 Profilo | Expert

Ottimo grazie ciao alla prossima
Mau67
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5