Link to home
Start Free TrialLog in
Avatar of blackjack020900
blackjack020900

asked on

Assignment of a value to a Record Set Object with ADO?

Why do we get a Runtime Error (-2147467259(80004005))? The Statement is done but the MoveNext-Methode cuts off.

With rs
.ActiveConnection = frmMain.m_dbConn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Source = sSQLAbr
.Open
End With

While Not rs.EOF
       
rs!VersandartenText = "hallo"
rsmerk.MoveNext
       
Wend



Avatar of deighton
deighton
Flag of United Kingdom of Great Britain and Northern Ireland image

'why not

While Not rs.EOF
                           
rs!VersandartenText = "hallo"
rs.MoveNext
                           
Wend




I'd also advice to use rs.Update so you make sure the datachanges will be committed, like

rs!VersandartenText = "hallo"
rs.Update
rs.MoveNext

cheerio
Avatar of blackjack020900
blackjack020900

ASKER

I don't want to make an update, because the field doesn't exist in the database it's only located in a Record Set.
ASKER CERTIFIED SOLUTION
Avatar of mark2150
mark2150

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The field was selected with the following statement:
sSQLAbr =
" select  versandart," &_
" VersandartenText= 'xxxxxxxxxxxxx'" &_
" from auftrag"
....

This means, the field does not exist in the DB but is only generated in the SELECT statement
Then it should crash in the assign statement rs!vers...="Hallo", and not in the movenext!! You don't have a field called VersandartenText because:
- it doesn't exist in the db
- you didn't add it as an alias in the select statement
Thanks!
It just took a while till I figured it out!