Hi pliz assist me, I need a code that can allow the login form to search for pin number stored in another form example when a customer enters the pin number and clicks ok button the login form searches if the pin number exists in the bank details form ..thanx in advance

Hi pliz assist me, I need a code that can allow the login form to search for pin number stored in another form example when a customer enters the pin number and clicks ok button the login form searches if the pin number exists in the bank details form ..thanx in advance

post code

Sorry I made an error the form should check if the pin number exist in the bank table in the database ..thanks

Hi,

The first thing you will need to do is create a connection string to your database. I will assume that you have already done this. We performed a similar function in a project I was working on and we created a function that would return whether or not the person logging in was a Manager. You should be able to tweak this code to make it work. NOTE: not being on the table threw an exception which was caught in the
catch exception portion of this code. Also, "gstrConn" was a global variable that holds the connection string (set in the form load event - gstrConn = My.Settings.SouthRefundsConn.ToString). You can use this technique or you can simply type out the entire connection string inside the parenthesis (like this "( Dim conn As New OleDbConnection(My.Settings.SouthRefundsConn.ToString)).
[Public Function MANAGERID()

'THIS FUNCTION READS THE tblMANAGEMENT TABLE IN THE REFUNDS DATABASE TO DETERMINE IF THE
'USER LOGGED INTO THE APPLICATION IS A MANAGER.
'IF THE USER IS ON tblMANAGEMENT, THE MANAGERID VALUE WILL BE THE EMPLOYEE'S ID.
'IF THE USER IS NOT ON tblMANAGEMENT, THE MANAGERID VALUE WILL BE SET TO ""
Dim conn As New OleDbConnection(gstrConn)
Dim strInsert As String
Dim returnValue As Object

Try
strInsert = "SELECT [EMPLOYEE_ID] FROM [tblMANAGEMENT] " & _
" WHERE [EMPLOYEE_ID] = '" & Mid(strRACF, 3, 4) & "'"

Dim cmd As New OleDbCommand

cmd.CommandText = strInsert
cmd.CommandType = CommandType.Text
cmd.Connection = conn
conn.Open()

returnValue = cmd.ExecuteScalar

Return returnValue

Catch ex As Exception
Return ""
Finally
conn.Close()
End Try

End Function]

Edited 5 Years Ago by jp_jones: didn't explain the gstrConn variable

Comments
use code tags next time

No, we were using Visual Studio 2005.

Visual Studio is an IDE, VB2008 is part of Visual Studio

This article has been dead for over six months. Start a new discussion instead.