-
Aug 18th, 2017, 05:00 AM
#1
Thread Starter
Junior Member
[RESOLVED] Where do the string.username and string.password save to?
So I need to know, where do all the string.username and string.password save to. I need like a lil database where i can check all the usernames and all the passwords.
The strings: https://gyazo.com/3b651ea429d098f64dd744edd218de7a
The code:
Option Strict On
Option Explicit On
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If My.Settings.UserName Is Nothing Then
My.Settings.UserName = New Specialized.StringCollection
End If
If My.Settings.Password Is Nothing Then
My.Settings.Password = New Specialized.StringCollection
End If
End Sub
' Register
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If My.Settings.UserName.Contains(TextBox1.Text) Then
MessageBox.Show(Me, "Username taken", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
My.Settings.UserName.Add(TextBox1.Text)
My.Settings.Password.Add(TextBox2.Text)
My.Settings.Save()
MessageBox.Show(Me, "Succesfully Registered!", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
' Log in
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim blnOK As Boolean
For j = 0 To My.Settings.UserName.Count - 1
If TextBox1.Text = My.Settings.UserName(j) AndAlso TextBox2.Text = My.Settings.Password(j) Then
blnOK = True
Exit For
End If
Next
If blnOK Then
MessageBox.Show(Me, "Succesfully loged in!", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show(Me, "Username or Password is incorrect!", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
End Class
-
Aug 18th, 2017, 05:13 AM
#2
Re: Where do the string.username and string.password save to?
Settings are stored in the config file. Settings with Application scope are read only and stored in the main config file, which you'll see in the Solution Explorer as App.config or Web.config, depending on the type of application. After building, the App.config file will be named after your program's EXE file and be stored in the same folder. Settings with User scope are read/write and have their default values stored in the main config file. Their current values will be stored on a per-user basis under each user's personal folder. "User" in this content means Windows user.
If you're going to use a database, which you generally would for something like this, then you can choose from a myriad of options. If you have Access installed, you could use an MDB or ACCDB file created in Access. You might also install SQL Server Express or just its LocalDB component and use a SQL Serve MDF data file. That will require all users of the app to have SQL Server Express installed. The other main alternative for a small-scale application is SQLite, which is a third-party product but what Microsoft recommend for file-based databases these days.
Regardless of which database you choose, the data access part will be basically the same. The types you use will come from different assemblies and/or namespaces, e.g. SqlClient for SQL Server or OleDb for Access, but the way you use them will be exactly the same. As a result, any ADO.NET information is relevant, even if it's for a different database.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|