i want a code for registration form in vb.net
and my project name is book bank system
can anyone please post the snippet for me
am using sqlserver2005 as backend

your prorgram? How can be your program, if you actually have nothing? :)
Please, tell us a bit more what exactly do you want.

You know, we are here to help, not doing code instead of you guys.
So, if you will not out some effort, at least giving us a decent issue explanation, why would we then waste out free time for you?
Come on...
Btw, do you have any code done yet?

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click

    Dim cmd As New SqlCommand
    Dim conn As New SqlConnection
    Dim sql = "Insert into login(fname,lname,user_id, username, password, reenter, usertype)values('" & txtfname.Text & "','" & txtlname.Text & "','" & txtid.Text & "','" & txtuname.Text & "','" & txtpass.Text & "','" & txtre.Text & "','" & ComboBox1.Text & "')"
    conn = New SqlConnection("Data Source=HOME-2BBEAE433A;Initial Catalog=book bank;User Id=sa;Password=mastro;")
    conn.Open()
    cmd = New SqlCommand(sql, conn)
    If txtfname.Text = "" Or txtlname.Text = "" Or txtid.Text = "" Or txtuname.Text = "" Or txtpass.Text = "" Or txtre.Text = "" Or ComboBox1.SelectedIndex = -1 Then
        MsgBox("error")
        conn.Close()
    Else
        cmd.ExecuteNonQuery()
        MsgBox("registration done ", MsgBoxStyle.OkOnly)
        If conn.State <> ConnectionState.Closed Then
            Me.Hide()
            Form3.Show()
        End If
    End If




    ths is my code it does a simple insertion only i want it in a proper form for registration,for example how can i check whether the people already registered and also how can i verify password & reenter password,the same name which already in database.....

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click

    Dim cmd As New SqlCommand
    Dim conn As New SqlConnection
    Dim sql = "Insert into login(fname,lname,user_id, username, password, reenter, usertype)values('" & txtfname.Text & "','" & txtlname.Text & "','" & txtid.Text & "','" & txtuname.Text & "','" & txtpass.Text & "','" & txtre.Text & "','" & ComboBox1.Text & "')"
    conn = New SqlConnection("Data Source=HOME-2BBEAE433A;Initial Catalog=book bank;User Id=sa;Password=mastro;")
    conn.Open()
    cmd = New SqlCommand(sql, conn)
    If txtfname.Text = "" Or txtlname.Text = "" Or txtid.Text = "" Or txtuname.Text = "" Or txtpass.Text = "" Or txtre.Text = "" Or ComboBox1.SelectedIndex = -1 Then
        MsgBox("error")
        conn.Close()
    Else
        cmd.ExecuteNonQuery()
        MsgBox("registration done ", MsgBoxStyle.OkOnly)
        If conn.State <> ConnectionState.Closed Then
            Me.Hide()
            Form3.Show()
        End If
    End If




    ths is my code it does a simple insertion only i want it in a proper form for registration,for example how can i check whether the people already registered and also how can i verify password & reenter password,the same name which already in database.....

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click

    Dim cmd As New SqlCommand
    Dim conn As New SqlConnection
    Dim sql = "Insert into login(fname,lname,user_id, username, password, reenter, usertype)values('" & txtfname.Text & "','" & txtlname.Text & "','" & txtid.Text & "','" & txtuname.Text & "','" & txtpass.Text & "','" & txtre.Text & "','" & ComboBox1.Text & "')"
    conn = New SqlConnection("Data Source=HOME-2BBEAE433A;Initial Catalog=book bank;User Id=sa;Password=mastro;")
    conn.Open()
    cmd = New SqlCommand(sql, conn)
    If txtfname.Text = "" Or txtlname.Text = "" Or txtid.Text = "" Or txtuname.Text = "" Or txtpass.Text = "" Or txtre.Text = "" Or ComboBox1.SelectedIndex = -1 Then
        MsgBox("error")
        conn.Close()
    Else
        cmd.ExecuteNonQuery()
        MsgBox("registration done ", MsgBoxStyle.OkOnly)
        If conn.State <> ConnectionState.Closed Then
            Me.Hide()
            Form3.Show()
        End If
    End If




    ths is my code it does a simple insertion only i want it in a proper form for registration,for example how can i check whether the people already registered and also how can i verify password & reenter password,the same name which already in database.....

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click

    Dim cmd As New SqlCommand
    Dim conn As New SqlConnection
    Dim sql = "Insert into login(fname,lname,user_id, username, password, reenter, usertype)values('" & txtfname.Text & "','" & txtlname.Text & "','" & txtid.Text & "','" & txtuname.Text & "','" & txtpass.Text & "','" & txtre.Text & "','" & ComboBox1.Text & "')"
    conn = New SqlConnection("Data Source=HOME-2BBEAE433A;Initial Catalog=book bank;User Id=sa;Password=mastro;")
    conn.Open()
    cmd = New SqlCommand(sql, conn)
    If txtfname.Text = "" Or txtlname.Text = "" Or txtid.Text = "" Or txtuname.Text = "" Or txtpass.Text = "" Or txtre.Text = "" Or ComboBox1.SelectedIndex = -1 Then
        MsgBox("error")
        conn.Close()
    Else
        cmd.ExecuteNonQuery()
        MsgBox("registration done ", MsgBoxStyle.OkOnly)
        If conn.State <> ConnectionState.Closed Then
            Me.Hide()
            Form3.Show()
        End If
    End If




    ths is my code it does a simple insertion only i want it in a proper form for registration,for example how can i check whether the people already registered and also how can i verify password & reenter password,the same name which already in database.....

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click

    Dim cmd As New SqlCommand
    Dim conn As New SqlConnection
    Dim sql = "Insert into login(fname,lname,user_id, username, password, reenter, usertype)values('" & txtfname.Text & "','" & txtlname.Text & "','" & txtid.Text & "','" & txtuname.Text & "','" & txtpass.Text & "','" & txtre.Text & "','" & ComboBox1.Text & "')"
    conn = New SqlConnection("Data Source=HOME-2BBEAE433A;Initial Catalog=book bank;User Id=sa;Password=mastro;")
    conn.Open()
    cmd = New SqlCommand(sql, conn)
    If txtfname.Text = "" Or txtlname.Text = "" Or txtid.Text = "" Or txtuname.Text = "" Or txtpass.Text = "" Or txtre.Text = "" Or ComboBox1.SelectedIndex = -1 Then
        MsgBox("error")
        conn.Close()
    Else
        cmd.ExecuteNonQuery()
        MsgBox("registration done ", MsgBoxStyle.OkOnly)
        If conn.State <> ConnectionState.Closed Then
            Me.Hide()
            Form3.Show()
        End If
    End If




    ths is my code it does a simple insertion only i want it in a proper form for registration,for example how can i check whether the people already registered and also how can i verify password & reenter password,the same name which already in database.....

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click

    Dim cmd As New SqlCommand
    Dim conn As New SqlConnection
    Dim sql = "Insert into login(fname,lname,user_id, username, password, reenter, usertype)values('" & txtfname.Text & "','" & txtlname.Text & "','" & txtid.Text & "','" & txtuname.Text & "','" & txtpass.Text & "','" & txtre.Text & "','" & ComboBox1.Text & "')"
    conn = New SqlConnection("Data Source=HOME-2BBEAE433A;Initial Catalog=book bank;User Id=sa;Password=mastro;")
    conn.Open()
    cmd = New SqlCommand(sql, conn)
    If txtfname.Text = "" Or txtlname.Text = "" Or txtid.Text = "" Or txtuname.Text = "" Or txtpass.Text = "" Or txtre.Text = "" Or ComboBox1.SelectedIndex = -1 Then
        MsgBox("error")
        conn.Close()
    Else
        cmd.ExecuteNonQuery()
        MsgBox("registration done ", MsgBoxStyle.OkOnly)
        If conn.State <> ConnectionState.Closed Then
            Me.Hide()
            Form3.Show()
        End If
    End If




    ths is my code it does a simple insertion only i want it in a proper form for registration,for example how can i check whether the people already registered and also how can i verify password & reenter password,the same name which already in database.....

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click

    Dim cmd As New SqlCommand
    Dim conn As New SqlConnection
    Dim sql = "Insert into login(fname,lname,user_id, username, password, reenter, usertype)values('" & txtfname.Text & "','" & txtlname.Text & "','" & txtid.Text & "','" & txtuname.Text & "','" & txtpass.Text & "','" & txtre.Text & "','" & ComboBox1.Text & "')"
    conn = New SqlConnection("Data Source=HOME-2BBEAE433A;Initial Catalog=book bank;User Id=sa;Password=mastro;")
    conn.Open()
    cmd = New SqlCommand(sql, conn)
    If txtfname.Text = "" Or txtlname.Text = "" Or txtid.Text = "" Or txtuname.Text = "" Or txtpass.Text = "" Or txtre.Text = "" Or ComboBox1.SelectedIndex = -1 Then
        MsgBox("error")
        conn.Close()
    Else
        cmd.ExecuteNonQuery()
        MsgBox("registration done ", MsgBoxStyle.OkOnly)
        If conn.State <> ConnectionState.Closed Then
            Me.Hide()
            Form3.Show()
        End If
    End If




    ths is my code it does a simple insertion only i want it in a proper form for registration,for example how can i check whether the people already registered and also how can i verify password & reenter password,the same name which already in database.....

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click

    Dim cmd As New SqlCommand
    Dim conn As New SqlConnection
    Dim sql = "Insert into login(fname,lname,user_id, username, password, reenter, usertype)values('" & txtfname.Text & "','" & txtlname.Text & "','" & txtid.Text & "','" & txtuname.Text & "','" & txtpass.Text & "','" & txtre.Text & "','" & ComboBox1.Text & "')"
    conn = New SqlConnection("Data Source=HOME-2BBEAE433A;Initial Catalog=book bank;User Id=sa;Password=mastro;")
    conn.Open()
    cmd = New SqlCommand(sql, conn)
    If txtfname.Text = "" Or txtlname.Text = "" Or txtid.Text = "" Or txtuname.Text = "" Or txtpass.Text = "" Or txtre.Text = "" Or ComboBox1.SelectedIndex = -1 Then
        MsgBox("error")
        conn.Close()
    Else
        cmd.ExecuteNonQuery()
        MsgBox("registration done ", MsgBoxStyle.OkOnly)
        If conn.State <> ConnectionState.Closed Then
            Me.Hide()
            Form3.Show()
        End If
    End If




    ths is my code it does a simple insertion only i want it in a proper form for registration,for example how can i check whether the people already registered and also how can i verify password & reenter password,the same name which already in database.....

For registering user, you basicly need his username and password. Username must me unique, that means it can ONLY be one (it must not repeat - its meant like ID).
To answer on your questions:
1. To check is user already registered: you need an sql query to check if this username exists in database:

Private Sub MyMethod()
    Dim IfUserExists As Boolean = CheckUserNameExistance(txtuname.Text)
            'user exists!!
            'notify by message about this user name already exists, and it must be changed
    If IfUserExists Then
            'user does not exist, so can continue
    Else
    End If
End Sub
Private Function CheckUserNameExistance(user As String) As Boolean
    Dim bExisting As Boolean = False
    Using conn As New SqlConnection("connString")
        Dim query As String = "SELECT UserName FROM Users WHERE UserName = @param"
        Using cmd As SqlCommand = New SqlComamnd(query, conn)
            Dim obj As Object = DirectCast(cmd.ExecuteScalar(), String)
            If obj IsNot Nothing Then
                bExisting = True
            End If
        End Using
    End Using
    Return bExisting
End Function
  1. How to verify the password and reennter password?
    QUESTION: What do you mean by verifying? To check its strenght? Or simply equality of both inserted strings?

Edited 4 Years Ago by Mitja Bonca: edited code

This article has been dead for over six months. Start a new discussion instead.