borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (VB Printing)Next Topic (develop case based reasoning) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Help! Vb6 Login at the server then verify using msaccess
Poster Message
mike
Level: Trainee

Registered: 20-03-2006

icon Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

hi, could anyone help me with programming? i need these things for my thesis. Vb6 Login at the server then verify using msaccess, then if the username and password is accepted the user will choose a workstation. and at the workstation he would be asked again his password to see if he's really the one who chose that worksation. then his name would appear in the workstation that he chose.

Pls help!!! i've no background in vb6 and msaccess. or at least, could anyone give me an idea/references on how to do these things.

Thnx in advance

15-05-2002 at 06:54 AM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

Just want to see if this is what you mean

1) Server program that will accept Username(UID) and password(PWD).

2)Verify input with values in accessDB.
3)If valid, then prompt for workstationID
4)at workstation, prompt for UID/PWD

Now the question is, do you mean to actually login to the PC (as in NT login), or just program login? If program login, then it's fairly simple:

On Server:
1) One program, ask for uid/pwd, check with database.
2) if valid, prompt for workstation - store workstation ID into table

On workstation:
1) same program, check access database for workstationID with UID/PWD
2) if exist, prompt for UID/PWD, compare to table

I didn't provide code since I'm not sure how you're asking for it to be done, although I'm assuming program login, not NT login.

15-05-2002 at 07:14 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

quote:
JLRodgers wrote:

yes! that's what i need. Yipee!!
15-05-2002 at 08:33 AM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

The following isn't everything you'll need to modify based on your requirements. you'll also need a reference to "Microsoft ActiveX Data objects 2.x" (where x is anything). It also assumes that you've already got an access db created. (although the code to create one's really easy).

It's not optimized, just created quickly.

Set the program's startup to "Sub Main()"

in a module:

Option Explicit

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Main()
    Dim dwLen As Long
    Dim strComputerName As String
    'Create a buffer
    strComputerName = String(32&, Chr(0))
    'Get the computer name
    GetComputerName strComputerName, 32&
    'get only the actual data
    strComputerName = Replace(strComputerName, Chr(0), "")
    If Login(strComputerName) Then
        frmLogin.Show vbModal
    End If
End Sub

Private Function Login(ByVal ComputerName As String) As Boolean
    On Error GoTo Err_Login
    
    Dim adc As New ADODB.connection
    Dim ars As New ADODB.Recordset
    
    Set adc = New ADODB.connection
    Set ars = New ADODB.Recordset
    
    Login = False
    
    adc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "LoginDBName.mdb;Persist Security Info=False"
    ars.Open "SELECT * FROM [UserList] WHERE Workstation='" & ComputerName & "'", adc, adOpenDynamic, adLockOptimistic
' If BOF and EOF then no data, therefore invalid
' True AND True = True, not True=false. False & false = false, not false=true
    Login = Not (ars.BOF And ars.EOF)
    
Err_Login:
    If ars.state = adstateopen Then ars.Close
    If adc.state = adstateopen Then adc.Close
    
    Set adc = Nothing
    Set ars = Nothing
    If Err.Description <> "" Then
    ' Do whatever you need for error messages
    End If
End Function

In the frmLogin:

Private Function ValidInfo(ByVal UID As String, ByVal PWD As String, ByVal Workstation As String) As Boolean
    On Error GoTo Err_ValidateInfo
    
    Dim adc As New ADODB.connection
    Dim ars As New ADODB.Recordset
    
    Set adc = New ADODB.connection
    Set ars = New ADODB.Recordset
    
    ValidInfo = False
    
    adc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "LoginDBName.mdb;Persist Security Info=False"
    ars.Open "SELECT * FROM [UserList] WHERE UID='" & UID & "' AND PWD='" & PWD & "'", adc, adOpenDynamic, adLockOptimistic
' Commented lines are for two tables, 1-users,2-workstations
' If BOF and EOF then no data, therefore invalid
' True AND True = True, not True=false. False & false = false, not false=true
'    ValidInfo = Not (ars.BOF And ars.EOF)
' One table
    If Not ars.BOF And Not ars.EOF Then
        ValidInfo = True
        ars.Fields("Workstation") = Workstation
        ars.Update
    End If
    
Err_ValidateInfo:
    If ars.state = adstateopen Then ars.Close
    If adc.state = adstateopen Then adc.Close
    
    Set adc = Nothing
    Set ars = Nothing
    If Err.Description <> "" Then
    ' Do whatever you need for error messages
    End If
End Function

Private Sub cmdOK_Click()
    ValidInfo txtUID.Text, txtPWD.Text, txtWorkstation.Text
End Sub

Of course, you'll need to change the Database name, and add controls, and change the names in this code for it to work, but it's a general idea at least.

15-05-2002 at 01:13 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

THNX so so much JL. i'l post again, regarding the progress of the program.

I've tried to access a database in  msaccess but an error always appears

can't find project or library

then

missing: microsoft activex data objects 2.6 library

but i know that the program you gave me would help a lot. Thnx

15-05-2002 at 02:57 PM
View Profile Send Email to User Show All Posts | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Re: Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

how did u do the program that fast. wow!! do you love to program?

JL, do you have some references on how to program in VB6 applied in LAN. i think it also uses tcp/ip and winsock, because i need it badly for the other objectives of my thesis. THnx again 8)

15-05-2002 at 03:09 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

Make sure that the reference is added, it won't work without it.

Programmed stuff since 1983 or so.

With the lan question... Add the Winsock control, it does most of the stuff for you automatically (instead of using the API). It's used for chat programs, connections via udp/tcp on any port on a pc. Creating a proxy server or sorts. Things of that nature.

If that's what you want, lookup the keywords: "Winsock", "chat", "proxy" or more detailed descriptions of what your looking for on any vb site or on the internet as a whole. There are a lot of different examples all over.

15-05-2002 at 03:24 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

hi, how could i add the references(microsoft activex data objects 2.6 library) ? is it in included in the installer? i can't make the program work. maybe if the references would be present the program would run smoothly.

Thnx!!

17-05-2002 at 11:30 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

Open the Project menu, it's under References.

(project/references)

17-05-2002 at 11:49 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

OK, thnx JL!!!

18-05-2002 at 12:49 AM
View Profile Send Email to User Show All Posts | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

got a problem again. it's missing! i think my compiler doesnt have microsoft activex data objects 2.6 library. and when i compile the program it says  missing: microsoft activex data objects 2.6 library. how can i put this into the references??

18-05-2002 at 12:54 AM
View Profile Send Email to User Show All Posts | Quote Reply
mike
Level: Trainee

Registered: 20-03-2006
icon Re: Help! Vb6 Login at the server then verify using msaccess  Archived to Disk

Hi!! i got it. the compiler has a ms activex data objects 2.5 library. thnx so much 4 ur time and effort. i really appreciate it.

I'll just post again f ever i have a problem in programming. thnx alot.

If i may ask, what's ur email add.? so i can just send you an email.

18-05-2002 at 01:30 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Help! Vb6 Login at the server then verify using msaccess
Previous Topic (VB Printing)Next Topic (develop case based reasoning) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder