Click here to Skip to main content
14,739,804 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,
I'm trying to write a basic client database software for my father with basic vb.net skills.

He has different types of businesses so he wants to store the clients in different databases.

I'm trying to write code for a login screen that opens a filedialog to load in an access db of choice.
Once selected it should show up in a textbox
it should have an option to save the location for future logins.

Once you press the connect button you should get another panel with a loginscreen to connect to that database. The login credentials are located within the database.

thanks all for helping a newbie out!

What I have tried:

in my loginscreen i have a "choose database" button, a textbox and a "connect button"

public class Form_Login
private sub btn_choose_click(sender as object, e as eventargs) handles btn_choose.Click

Dim strtext as string
OpenFileDialog1.InitialDirectory = "C:\mydbsoft"
OpenFileDialog1.Title = "Choose your database"
OpenFileDialog1.ShowDialog()

strtext = OpenFileDialog1.FileName
txtLocation.text = strtext

end sub

private sub btn_connect_click(sender as object, e as eventargs) handles btn_connect.Click)

"here i need code to actually connect to that database that i "loaded""

end sub

private sub btn_login_click
(sender as object, e as eventargs) handles btn_login.Click)

"here i need code to login with credentials that are stored in a table in that database"

end sub

end class
Posted
Updated 25-Sep-20 8:17am

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

I'd start by looking at the OpenFileDialog and the format of Access connection strings:
OpenFileDialog Class (System.Windows.Forms) | Microsoft Docs[^]

Access connection strings - ConnectionStrings.com[^]

But ... using different DB's for each client is a bad idea. Much better to keep a single DB and a table of clients, then relate each other table entry to a specific client.
It's a lot easier to manage, and much, much easier when you want to start analysing the data later on.
   
Hello again, apologies for not showing my progress, i'm not getting paid for this programming but with love from my father, he's still managing his clients in 20 access files he made 20y ago.
here's my loginscreencode that is already done. (if you want screenshots or a movie what my software looks like, ask , i'll try to provide.
As you can see the loginscreen is basically done, but my knowledge about connecting and preserving database connections is kinda nill.

Public Class LoginScreen

    Private Sub Loginscreen_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ProgressBar2.Minimum = 0
        ProgressBar2.Maximum = 100
        ProgressBar2.Visible = False
        Panel1.Visible = False

    End Sub
    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Application.Exit()
    End Sub
    Private Sub btnExit2_Click(sender As Object, e As EventArgs) Handles btnExit2.Click
        Application.Exit()
    End Sub

    Private Sub tmrLogin_Tick(sender As Object, e As EventArgs) Handles tmrLogin.Tick
        ProgressBar2.Value = ProgressBar2.Value + 20
        lblLoginMessages.Text = ProgressBar2.Value & "%" & " Completed"
        If ProgressBar2.Value >= 100 Then
            tmrLogin.Enabled = False
            If txtUser.Text = "azert" And txtPassword.Text = "azert" Then
                ProgressBar2.Value = 0
            Else
                lblLoginMessages.Text = "Wrong credentials, Try again!"
                pboxClosed.Visible = True
                PboxOpen.Visible = False

                ProgressBar2.Value = 0
                txtPassword.Text = ""
                txtUser.Text = ""
            End If
        End If
    End Sub

    Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        ProgressBar2.Visible = True
        tmrLogin.Enabled = True

        pboxClosed.Visible = False
        PboxOpen.Visible = True
        ''navraag doen om dit correct in te stellen! ! ! ! !! 
        'If ProgressBar2.Value = 100 Then
        'lblLoginMessages.Text = "Logging in..."
        Me.Hide()
            Mainscreen.Show()
        'End If

    End Sub

    Private Sub btnDBConnect_Click(sender As Object, e As EventArgs) Handles btnDBConnect.Click
        If Panel1.Visible = False Then
            Panel1.Visible = True
        Else
            Application.Exit()

        End If
    End Sub

    Private Sub txtUser_TextChanged(sender As Object, e As EventArgs) Handles txtUser.TextChanged

    End Sub

    Private Sub btnChoose_Click(sender As Object, e As EventArgs) Handles btnChoose.Click
        Dim strtext As String
        OpenFileDialog1.InitialDirectory = "F:\fordad\databaseVBNET"
        OpenFileDialog1.Title = "Choose your Database"
        OpenFileDialog1.ShowDialog()

        strtext = OpenFileDialog1.FileName
        txtDatabaselocationshow.Text = strtext
    End Sub

    Private Sub tmrshowloginpanel_Tick(sender As Object, e As EventArgs) Handles tmrshowloginpanel.Tick
        Panel1.Width += 5
        If Panel1.Width >= 700 Then
            tmrshowloginpanel.Stop()
        End If
    End Sub

End Class
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900