Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   How to find a record from recordset? (http://www.go4expert.com/forums/record-recordset-t4130/)

nadunalexander 4May2007 12:44

How to find a record from recordset?
 
there is a recordset with name and address. name is primary key. I have to update some one address to his new address. How can i set cursor to the exact record without searching in all the records? I used while loop to set cursor. But it is very slow.

This is my code
Code:

recordset.movefirst
Do While Not recordset.EOF
                If recordset.Fields(0).Value = txtName Then
                    recordset.Fields(1).Value = txtNewAddress
                    Exit Do
                End If
                recordset.MoveNext
 Loop


pradeep 4May2007 14:07

Re: How to find a record from recordset?
 
:| select by the primary key and update it!

nadunalexander 5May2007 21:05

Re: How to find a record from recordset?
 
Can u explain some more. I dont know database deeply

pradeep 6May2007 00:03

Re: How to find a record from recordset?
 
Code: ASP

recordset.open oConn,"SELECT * FROM table WHERE primary_key=" & pValue

if Not recordset.EOF
  recorset.Fields(1).Value = "something new"
  recordset.update
end if


something like this...

nadunalexander 6May2007 17:49

Re: How to find a record from recordset?
 
Thank you for ur code. But my problem is not updating table. updating a recordset record that has more than one records


All times are GMT +5.5. The time now is 15:01.