hi, am new to ADO and the below code (for updating recordset) has some problem
================> Code
cnn.Open (varGlobal.connectionstring())
rs.Open "SELECT distinct r.cod_location," _
& " r.cod_bankarr,c.txt_locname, c.txt_address" _
& " FROM tbl_RetUpload as r, tbl_corddetails as c " _
& "WHERE r.cod_location=c.cod_location And r.dat_debit<(date()-7) And r.typ_status='N' and r.dat_debit = #" & Format("03/06/2002", "mm/dd/yyyy" & "#", cnn, adOpenStatic, adLockOptimistic
Do While rs.EOF = False
vloc = rs.Fields("cod_location"
newrs.ActiveConnection = cnn
newrs.Source = "SELECT distinct r.cod_client,r.nbr_micr, r.dat_debit," _
& " r.typ_status, r.amt_chkamt,r.cod_bankarr,c.cod_location, c.txt_locname, c.txt_address" _
& " FROM tbl_RetUpload as r, tbl_corddetails as c " _
& "WHERE r.cod_location=c.cod_location And r.dat_debit<(Date() - 7) And r.typ_status='N' and r.dat_debit = #" & Format("03/06/2002", "mm/dd/yyyy" & "#" _
& "and r.cod_location='" & vloc & "'"
newrs.LockType = adLockOptimistic
newrs.CursorType = adOpenStatic
newrs.Open
Do While newrs.EOF = False
'//// DO STUFF like writting to a word file
newrs("typ_status" = "L"
newrs.Update
Loop
newrs.Close
Set newrs = Nothing
rs.MoveNext
Loop
Give an error when newrs.update happens
-> Error -> Too Few Parameters Expected 11.
if i remove the update stmt. it says the Database is locked for editing.
Niraj
================> Code
cnn.Open (varGlobal.connectionstring())
rs.Open "SELECT distinct r.cod_location," _
& " r.cod_bankarr,c.txt_locname, c.txt_address" _
& " FROM tbl_RetUpload as r, tbl_corddetails as c " _
& "WHERE r.cod_location=c.cod_location And r.dat_debit<(date()-7) And r.typ_status='N' and r.dat_debit = #" & Format("03/06/2002", "mm/dd/yyyy" & "#", cnn, adOpenStatic, adLockOptimistic
Do While rs.EOF = False
vloc = rs.Fields("cod_location"
newrs.ActiveConnection = cnn
newrs.Source = "SELECT distinct r.cod_client,r.nbr_micr, r.dat_debit," _
& " r.typ_status, r.amt_chkamt,r.cod_bankarr,c.cod_location, c.txt_locname, c.txt_address" _
& " FROM tbl_RetUpload as r, tbl_corddetails as c " _
& "WHERE r.cod_location=c.cod_location And r.dat_debit<(Date() - 7) And r.typ_status='N' and r.dat_debit = #" & Format("03/06/2002", "mm/dd/yyyy" & "#" _
& "and r.cod_location='" & vloc & "'"
newrs.LockType = adLockOptimistic
newrs.CursorType = adOpenStatic
newrs.Open
Do While newrs.EOF = False
'//// DO STUFF like writting to a word file
newrs("typ_status" = "L"
newrs.Update
Loop
newrs.Close
Set newrs = Nothing
rs.MoveNext
Loop
Give an error when newrs.update happens
-> Error -> Too Few Parameters Expected 11.
if i remove the update stmt. it says the Database is locked for editing.
Niraj