seek and update

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

seek and update

Post by sal21 »

pseudo code:

conn.begintrans
do until....

rs.seek VAR, 1

if rs.eof then

conn.execute "insert into table filed1=''" & myvar & "'''

end if

loop
conn.commistrans

prob!!!! the insert statement dont update the filed!

note:
- i have the a primary key without duplicate in filed1
- the until ....loop is refered to read line by line a txt file
- is a seek ado

in this case have error "not possible to insert a duplicate value ...ecc"

peraph the insert statement is effective only when the code go in commitrans?

User avatar
HansV
Administrator
Posts: 78625
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: seek and update

Post by HansV »

The syntax for INSERT INTO with literal values is

INSERT INTO tablename (field1, field2, ...) VALUES (value1, value2, ...)

So change the line

Code: Select all

        conn.execute "insert into table filed1=''" & myvar & "'''
to

Code: Select all

        conn.Execute "INSERT INTO table (filed1) VALUES ('" & myvar & "')"
Best wishes,
Hans