0

I need your help

i'm using access database
create simple login form
in the database record Username is Admin or Password is Admin
so i wanna need this add username and save record ask me record already available

how to do this on vb.net 2010 or 2012

looks like this
bc385977b47cc9aebe01cf26e6fcbf20

Edited by nikunjkacha

3
Contributors
2
Replies
29
Views
3 Years
Discussion Span
Last Post by Santanu Das
0

Some days ago I do the same as you want.

 Private Sub ToolStripLabel4_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripLabel4.Click

        If (ValidateUser() = False) Then Return

        Dim UserCommand As New System.Data.SqlClient.SqlCommand

        If distributionDB.State = ConnectionState.Closed Then
            distributionDB.Open()
        End If

        UserCommand.CommandText = "Select Count(UserID) From DistUser Where UserID=@UsID"
        UserCommand.Parameters.Add("@UsID", SqlDbType.VarChar, 50).Value = uID
        UserCommand.Connection = distributionDB

        Dim uCount As Integer = UserCommand.ExecuteScalar()
        UserCommand.Parameters.Clear()
        UserCommand.Dispose()
        distributionDB.Close()

        If uCount > 0 Then
            Dim x As String = String.Format("User Name {0} already exists.{1}Please input a unique user name.", TextBox1.Text, vbCrLf)
            MsgBox(x, MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "User...")
            Exit Sub
        End If

        Me.DialogResult = Windows.Forms.DialogResult.OK

    End Sub

    Private Function ValidateUser() As Boolean
        On Error Resume Next

        If (Trim(TextBox1.Text) = "") Then
            MsgBox("The User name is required.", MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, ApplName)
            TextBox1.Focus()
            Return False
        End If

        Return True

    End Function

You can try it if you like it. I also Used MsSQL database system, you have to use the OleDb Connection for your Access Database. Alter them and try it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.