 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
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 |
|
|
mike Level: Trainee
 Registered: 20-03-2006
|
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 |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
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 |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
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 |
|
|
mike Level: Trainee
 Registered: 20-03-2006
|
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 |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
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 |
|
|
mike Level: Trainee
 Registered: 20-03-2006
|
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 |
|
|
|
|
 |
 |