Hi vereato,
Refer below code.
HTML
<table>
<tr>
<td>User Name</td>
<td>
<asp:TextBox ID="textusername" runat="server" />
</td>
</tr>
<tr>
<td>Password</td>
<td>
<asp:TextBox ID="textpassword" runat="server" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button Text="Login" runat="server" OnClick="OnLogin" />
</td>
</tr>
</table>
Code
Login
Protected Sub OnLogin(sender As Object, e As EventArgs)
Session("Username") = textusername.Text
Session("password") = textpassword.Text
Response.Redirect("Default.aspx")
End Sub
Default
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Load_Username()
End If
End Sub
Private Sub Load_Username()
Dim ConnStr As String = ConfigurationManager.ConnectionStrings("MySQLConnect").ConnectionString
Using Conn As New MySqlConnection(ConnStr)
Dim Cmd As MySqlCommand = New MySqlCommand("SELECT User_Name,First_Name,Age,Email FROM tbl_users WHERE User_Name=@User_Name", Conn)
Cmd.Parameters.AddWithValue("@User_Name", Session("User_Name").ToString())
Dim Sda As MySqlDataAdapter = New MySqlDataAdapter(Cmd)
Dim Dt As DataTable = New DataTable()
Sda.Fill(Dt)
If Dt.Rows.Count > 0 Then
Dashboard_LinkBtn_User_Name.Text = Dt.Rows(0)("User_Name").ToString()
Dashboard_Lbl_DB_First_Name.Text = Dt.Rows(0)("First_Name").ToString()
Dashboard_Lbl_DB_Age.Text = Dt.Rows(0)("Age").ToString()
Dashboard_Lbl_DB_Email.Text = Dt.Rows(0)("Email").ToString()
Else
Lbl_Username.Text = "Your Username is incorrect"
Lbl_Username.ForeColor = System.Drawing.Color.Red
End If
End Using
End Sub