|
-
Jan 13th, 2000, 02:47 AM
#1
Thread Starter
New Member
I was wondering on how I should do to be able to search a database for a name and then display that persons adress in a textbox.
It shouldn't be that hard to do but since I'm in a hurry (the program is a schoolwork that should be finished soon) I won't have the time to experiment myself since there are other functions that must be programmed.
If anyone could help me by writing down the code I would be grateful.
Please include explanations if needed so that I won't get totally confused and have to spend the entire night trying to figure it out :-)
-
Jan 13th, 2000, 04:54 AM
#2
Frenzied Member
If you can use SQL it's easier - you can do a simple search using an SQL string that's something like this:
"SELECT address FROM DBName WHERE Name='" & strName & "';"
You should be able to use that to stick the address value in a text box pretty easily. I've only ever used SQL with ASP/VBScript so I'm not sure how you use it with VB. Your help files should tell you how.
If you can't/don't want to use SQL then you can use code like this:
Dim strName strAddress as String
Data1.Recordset.Movefirst
Do until EOF
If Data1.Recordset("Name")=strName then
strAddress=Data1.Recordset("Address")
exit do
Else
Data1.Recordset.Movenext
End If
Loop
Text1.Text=strAddress
I think that should do it. So long as you enter a valid name. If you need anything more specific, post again.
-
Jan 13th, 2000, 12:46 PM
#3
Lively Member
this is the sample codes i have done:
Dim rsForum As ADODB.Recordset
Dim strSQL As String
Dim Customer as string
strSQL = "SELECT * FROM tblBoardCat WHERE BCID=" & BCID
Set rsForum = New ADODB.Recordset
rsForum.Open strSQL, DB_CONNECT
Customer=rsForum("Customer")
Set rsForum = Nothing
You'll need to include Microsoft ADO 2.0 or 2.1 in the reference of your project.
-
Jan 13th, 2000, 03:24 PM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|