In this Post You Can learn about Registration and Login Form in Vb.Net Apply the below coding or watch our complete tutorials
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.IO
Imports System.Configuration
Public Class Form1
Dim connectionString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=c:\users\pc1\documents\visual studio 2010\Projects\WindowsApplication23\WindowsApplication23\Database1.mdf;Integrated Security=True;User Instance=True"
Dim cn As New SqlConnection(connectionString)
Dim cmd As New SqlCommand
Dim dr As SqlDataAdapter
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox2.Text.Trim() = TextBox3.Text.Trim() Then
Dim str As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=c:\users\pc1\documents\visual studio 2010\Projects\WindowsApplication23\WindowsApplication23\Database1.mdf;Integrated Security=True;User Instance=True"
Dim sql As String = "INSERT INTO Table1 (Email,Pass,Name) values (@Email,@Pass,@Name)"
Using Conn As New SqlConnection(str)
Using cmd As New SqlCommand(sql, Conn)
Conn.Open()
cmd.Parameters.AddWithValue("@Email", TextBox4.Text)
cmd.Parameters.AddWithValue("@Pass", TextBox2.Text)
cmd.Parameters.AddWithValue("@Name", TextBox1.Text)
Dim value = cmd.ExecuteScalar()
If value > 0 Then
MessageBox.Show("Signup sucessfully!")
Else
MessageBox.Show("Signup Unsucessfully!")
End If
End Using
End Using
Else
MsgBox("confirmation password do not match")
End If
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=c:\users\pc1\documents\visual studio 2010\Projects\WindowsApplication23\WindowsApplication23\Database1.mdf;Integrated Security=True;User Instance=True"
Dim sql As String = "select count(*) from Table1 where Email=@Email and Pass=@Pass"
Using Conn As New SqlConnection(str)
Using cmd As New SqlCommand(sql, Conn)
Conn.Open()
cmd.Parameters.AddWithValue("@Email", TextBox5.Text)
cmd.Parameters.AddWithValue("@Pass", TextBox6.Text)
Dim value = cmd.ExecuteScalar()
If value > 0 Then
MessageBox.Show("Login sucessfully!")
Label11.Text = TextBox5.Text
TextBox5.Text = ""
TextBox6.Text = ""
Else
MessageBox.Show("Incorrect Email or Password")
End If
End Using
End Using
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Dim str As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=c:\users\pc1\documents\visual studio 2010\Projects\WindowsApplication23\WindowsApplication23\Database1.mdf;Integrated Security=True;User Instance=True"
Dim sql As String = "select count(*) from Table1 where Pass=@Pass"
Using Conn As New SqlConnection(str)
Using cmd As New SqlCommand(sql, Conn)
Conn.Open()
cmd.Parameters.AddWithValue("@Pass", TextBox7.Text)
Dim value = cmd.ExecuteScalar()
If value > 0 Then
If TextBox8.Text.Trim() = TextBox9.Text.Trim() Then
Dim cmd1 As New SqlCommand
cmd1.Connection = cn
cmd1.CommandText = ("UPDATE Table1 SET Email = @Email ,Pass = @Pass WHERE Email = @Email")
' cmd.CommandText = ("UPDATE Table1 SET number = @number ,name = @name ,cnic = @cnic, address = @address,image = @image WHERE id = @id")
Dim ms As New MemoryStream()
cmd1.Parameters.Add("@Email", SqlDbType.VarChar).Value = Label11.Text
cmd1.Parameters.Add("@Pass", SqlDbType.VarChar).Value = TextBox8.Text
'cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = TextBox8.Text
cn.Open()
cmd1.ExecuteNonQuery()
cn.Close()
MsgBox("Password Changed Successfully", MsgBoxStyle.Information, "Done!")
Else
MsgBox("confirmation password do not match")
End If
Else
MessageBox.Show("old password not match")
End If
End Using
End Using
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
End Sub
End Class
Imports System.IO
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Save File In .txt (Notepad)
Dim Save As New SaveFileDialog()
Dim myStreamWriter As System.IO.StreamWriter
Save.Filter = "Text [*.txt*]|*.txt"
Save.CheckPathExists = True
Save.Title = "Save File"
Save.ShowDialog(Me)
Try
myStreamWriter = System.IO.File.AppendText(Save.FileName)
myStreamWriter.Write(TextBox1.Text)
myStreamWriter.Flush()
Catch ex As Exception
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
System.IO.File.WriteAllText(SaveFileDialog1.FileName, TextBox1.Text)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SaveFileDialog1.Filter = "Word Documents|*.doc"
End Sub
End Class
the code good but she give me error i don't know why
ReplyDeleteLogin And Registration Form In Vb.Net With Database >>>>> Download Now
ReplyDelete>>>>> Download Full
Login And Registration Form In Vb.Net With Database >>>>> Download LINK
>>>>> Download Now
Login And Registration Form In Vb.Net With Database >>>>> Download Full
>>>>> Download LINK b8