English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

for example, if i want to compare a users' input to what is stored in the database, how do i ?

2006-06-27 04:51:31 · 2 answers · asked by David R 1 in Computers & Internet Programming & Design

2 answers

If you want to compare what the user inputed, you will have to modify what admiralbob77 wrote as follows:

Sub CheckDB(SomeValue as String)
Dim ConnStr as string
ConnStr = "you have to put a " & _
"connection string in here."
Dim SQL as string
Dim ObjConn as new ADODB.Connection
Dim ObjRec as ADODB.Recordset
SQL = "select * from Records " & _
"WHERE Value = '" & _
SomeValue & "'"
ObjConn.Open ConnStr
Set ObjRec = _
ObjConn.Execute(SQL)
if ObjRec.EOF = True then
'the value is not in the database
Else
'Now check the user input here, let's say you have a textbox named txtUserInput
if ObjRec.Fields("FieldName").Value = Me.txtUserInput.Text then
'Do processing here
end if
End if
ObjConn.Close
Set ObjRec = nothing
Set ObjConn = nothing
End Sub

2006-06-27 06:42:28 · answer #1 · answered by adam j 1 · 0 0

Sub CheckDB(SomeValue as String)
Dim ConnStr as string
ConnStr = "you have to put a " & _
"connection string in here."
Dim SQL as string
Dim ObjConn as new ADODB.Connection
Dim ObjRec as ADODB.Recordset
SQL = "select * from Records " & _
"WHERE Value = '" & _
SomeValue & "'"
ObjConn.Open ConnStr
Set ObjRec = _
ObjConn.Execute(SQL)
if ObjRec.EOF = True then
'the value is not in the database
Else
'the value is in the database
End if
ObjConn.Close
Set ObjRec = nothing
Set ObjConn = nothing
End Sub

2006-06-27 12:38:36 · answer #2 · answered by evolver 6 · 0 0

fedest.com, questions and answers