borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincani

AndreaVB Home | News Home | Forum Home | Downloads | Register | Search | PM | Profile

Previous Topic (4 Digit Code Display)Next Topic (Adding data in database?) New Topic Post Reply
AndreaVB OnLine : VB General : to check column from primary key
Poster Resource
cempaka
Level: Big Cheese

Registered: 03-03-2009
Posts: 19
icon to check column from primary key

hi all..
im a newbie in VB

i am doing a project on access door with fingerprint..but not all person in the database can enter all door....certain doors for certain people..
how can i check another column in the database after i prompt for the primary key?

for example, entering the office..i want to check what is the position in the company. i prompt for the ID number first. then, from the person's ID number, i want to check other column from the same table..

how do i code it?
thanks a lot..

03-03-2009 at 09:09 AM
View Profile Send Email to User Show All Posts | Add Comment
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 606
icon Re: to check column from primary key

Run this Query against your database:-

(Where 'lngID' is your users ID number)

"SELECT AccessPermissions.CompanyPosition FROM AccessPermissions WHERE (AccessPermissions.UserID = " & lngID & ")"



____________________________
multi-tasking - the ability to hang more than one app. at the same time.

10-03-2009 at 10:18 AM
View Profile Send Email to User Show All Posts | Add Comment
cempaka
Level: Big Cheese

Registered: 03-03-2009
Posts: 19
icon Re: to check column from primary key

thanks geoff
i tried the code.
but still failed..
can somebody help me..in this part..
the database table name is User.
InputUser is the input from the user after promted from inputBox.
the level id shows the permission. if the level id is "1", then he/she allowed to enter.


Dim sSQL As String
sSQL = "SELECT User.Level_ID FROM User WHERE (User.User_ID = " & InputUser & ")"

If Level_ID = "1" Then
MsgBox "YES.YOUR ACCESS IS GRANTED!"
Else
MsgBox "SORRY. YOUR ACCESS IS DENIED"
End If

10-03-2009 at 03:51 PM
View Profile Send Email to User Show All Posts | Add Comment
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 606
icon Re: to check column from primary key

The SQL Statement is constructed OK, but you do not show any code where you apply the sSQL to your database connection object to return a Recordset, so I cannot comment on why you are not getting the expected return. However, your problem could well be that you have called your table "User" - this is a Reserved word in MS SQL-Server, and technically speaking User_ID should also not be used as this is recognised by SQL-Server as an inbuilt Function -
SELECT USER_ID('YourName') would return your user's database identification number in the current database -

I would suggest you change the table name (eg: DoorUsers ) and change the column User_ID to DoorUser_ID then try again.



____________________________
multi-tasking - the ability to hang more than one app. at the same time.

11-03-2009 at 02:38 PM
View Profile Send Email to User Show All Posts | Add Comment
cempaka
Level: Big Cheese

Registered: 03-03-2009
Posts: 19
icon Re: to check column from primary key

thanks geoff..
actually the User and User_ID is just example..
because i'm using malay for my database..thats why i replace the word with english..

for 1 door, i manage to edit the coding..
but for another door, i dont know why it doesnt work even i use the same coding..

this is for the door that i manage to make it..

sSQL = "select * from DoorUser where DoorUser_ID = " & InputDoor1 & ""
    rs.Open sSQL, cn, adOpenDynamic, adLockOptimistic
        
          If rs!level_id = "1" Then
                MsgBox "YES.YOUR ACCESS IS GRANTED!"
            Else
                MsgBox "SORRY. YOUR ACCESS IS DENIED"
                End If



but for another door, i copy the same coding but it was failed.

sSQL = "select * from DoorUser where DoorUser_ID = " & InputDoor2 & ""
    rs.Open sSQL, cn, adOpenDynamic, adLockOptimistic
        
        
            If rs!Position_ID <> "NormalUser" Then
                MsgBox "YES.YOUR ACCESS IS GRANTED!"
            Else
                MsgBox "SORRY. YOUR ACCESS IS DENIED"
                End If
        

thanks..

11-03-2009 at 04:38 PM
View Profile Send Email to User Show All Posts | Add Comment
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 606
icon Re: to check column from primary key

Have you tried the SQL Statement with the brackets around the "WHERE" clause as in my original example? I notice you are now reading the value of another field in the table, is the "Position_ID" a String value, I would expect a field called _ID to be a Long Integer value pointing to the Primary Key of another table (in this case a table containing a list of "Positions")
What is the Error that you are receiving and when is it raised?


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

12-03-2009 at 07:41 AM
View Profile Send Email to User Show All Posts | Add Comment
cempaka
Level: Big Cheese

Registered: 03-03-2009
Posts: 19
icon Re: to check column from primary key

hi there..
sorry for late feedback..
i'd settled my problem after i replaced the 'space' with 'underscore'..

thanks to all..

my next problem is i do not know how to connect the device to my application..

i bought a fingerprint scanner with smart card reader..
but the authentication will be done only between live fingerprint with the fingerprint stored in the smart card..
my question is:
1) how can i modify the source code to be used in my application
2) how to move the data after checked in the database to the smart card?

thanks...

17-03-2009 at 11:13 AM
View Profile Send Email to User Show All Posts | Add Comment
AndreaVB OnLine : VB General : to check column from primary key
Previous Topic (4 Digit Code Display)Next Topic (Adding data in database?)New Topic 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-2010 Andrea Tincaniborder