Earn Extra Money

Login Form (WPF) with MySQL




Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnSubmit.Click
Dim sqlconn As New MySqlConnection("Server=localhost;User Id=root;Password='';Database=risenlordmember")
If cbmode.Text = "Administrator" Then

Try

Dim sqlquery As String = "SELECT * From password WHERE username ='" & txtUsername.Text & "';"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As MySqlCommand = New MySqlCommand


sqlconn.Open()

command.CommandText = sqlquery
command.Connection = sqlconn
adapter.SelectCommand = command
data = command.ExecuteReader



While data.Read()
If data.HasRows() = True Then
If data(2).ToString = txtPassword.Password Then
MsgBox("Login Successful!", vbInformation, "Welcome Admin")

Else

Dim Notification As String
Notification = MsgBox("Wrong Username/Password, Try again?", vbOKCancel + vbCritical, "Failed!")
txtUsername.Clear()
txtPassword.Clear()

If Notification = vbOK Then

sqlconn.Open()

ElseIf Notification = vbCancel Then
Me.Close()

End If

End If

End If

End While


sqlconn.Close()








Catch ex As Exception

Finally
sqlconn.Dispose()

End Try



ElseIf cbmode.Text = "Member" Then

Try

Dim sqlquery As String = "SELECT * From password WHERE member_id ='" & txtUsername.Text & "';"
Dim data As MySqlDataReader
Dim adapter As New MySqlDataAdapter
Dim command As MySqlCommand = New MySqlCommand


sqlconn.Open()

command.CommandText = sqlquery
command.Connection = sqlconn
adapter.SelectCommand = command
data = command.ExecuteReader



While data.Read()
If data.HasRows() = True Then
If data(2).ToString = txtPassword.Password Then
MsgBox("Login Successful!", vbInformation, "Welcome Member")


Else

Dim Notification As String
Notification = MsgBox("Wrong Username/Password, Try again?", vbOKCancel + vbCritical, "Failed!")
txtUsername.Clear()
txtPassword.Clear()


If Notification = vbOK Then

sqlconn.Open()

ElseIf Notification = vbCancel Then
Me.Close()

End If

End If

End If

End While


sqlconn.Close()

Catch ex As Exception

Finally
sqlconn.Dispose()

End Try

End If


End Sub

Login Form (WPF)

Just trying :)
Underconstruction.. hehe

not a PRO..

Tools Req:

Microsoft Expression Blend
Language: VB.net
Database: MsSQL/MySQL


?php$dbname = 'risenlordmembers';


if (!mysql_connect('localhost', 'root', ''))

{ echo 'Could not connect to mysql'; exit;

}

$query="SELECT * FROM risenlordmembers.people p;";

$result=mysql_query($query);

$row=mysql_fetch_assoc($result);

$ID=$row['member_id'];

$LNAME=$row['lastname'];

$FNAME=$row['firstname'];

$BDAY=$row['birthday'];

$AGE=$row['age'];


echo "MEMBER'S ID ".$ID."
LASTNAME ".$LNAME.",
FIRSTNAME ".$FNAME.",
BIRTHDAY ".$BDAY.",
AGE ".$AGE;

?

Next Project: Loaning/Lending System (Under Counstruction)


Register a member ( Admin Mode)

Edit Member (Admin Mode)



Admin Mode



Login Form


Member Portal



codes will be release SOON :)

Sample Program of VB.net Connected to MySQL


Imports MySql.Data.MySqlClient

Public Class Form1

Dim ServerString As String = "Server=localhost;User Id=root;Password='';Database=youtube"

Dim SQLConnection As MySqlConnection = New MySqlConnection





Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load







SQLConnection.ConnectionString = ServerString





Try

If SQLConnection.State = ConnectionState.Closed Then

SQLConnection.Open()

MsgBox("Successfully connected to mysql database")

Else

SQLConnection.Close()

MsgBox("Connection Failed")





End If

Catch ex As Exception

MsgBox(ex.ToString)

End Try

End Sub

Public Sub SaveNames(ByRef SQLStatement As String)

Dim cmd As MySqlCommand = New MySqlCommand

With cmd

.CommandText = SQLStatement

.CommandType = CommandType.Text

.Connection = SQLConnection

.ExecuteNonQuery()





End With





SQLConnection.Close()

MsgBox("Successfully Added")

SQLConnection.Dispose()





End Sub





Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click

Dim SQLStatement As String = "INSERT INTO people(name) VALUES('" & txtName.Text & "')"





SaveNames(SQLStatement)

End Sub





Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

txtName.Text = " "





End Sub

End Class