Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RV Insert Update Delete Operation with MS SQL 2005 Express

Status
Not open for further replies.

Yosua

Programmer
Aug 23, 2011
25
Hi All
I've had a problem when I change SPT to RV n my program.
So when I change
Code:
SQLEXEC(s_Connect,"INSERT INTO tb_user values (?id,?pwd,?name,?photo))")
to
Code:
INSERT INTO vUser values (?id,?pwd,?name,?photo)
TABLEUPDATE()

vUser is a RV
It shows "syntax error" when I run it

Did I do something wrong?
Can you please tell me how to properly insert and update by RV?

Thanks in advance for any solution and feedback

Yosua Wisnu

 
You can use the ?variable syntax for view parameters, you can use it in inserts done via SQLEXEC, but not for insert-sql you do inside foxpro. In this case it doesn't matter, if the insert goes into a view or table or cursor, you must use vfp sql here, and that does alloe macro substitution, but not parameterisation.

In this case it should be easy, once variables id,pwd,name,photo are defined, you just do:
INSERT INTO vUser values (id,pwd,name,photo)

Keep in mind: To vfp SQL is language integrated, there is no layer needing to forward variables into the sql string, vfp executes it directly, and so you can simply specify variables for values.

If the variable names are identicl to field names, you will need to specify you want to use the variables via m.id,m.pwd,m.name,m.photo, but the same goes for the case using ? in SQLEXEC: ?expression will evaluate the expression, no matter if it's variables or fields or functions...

You know better what exactly you need, we don't even know the field names of your view and remote table.

But in short: ?var is the wrong syntax for speicifying parameters within foxpro, inside vfp the syntax is the same for sql than for anything else, eg you also execute function without prefixing variables or expression you pass into them with question marks, do you?

Bye, Olaf.

Bye, Olaf.
 
Thanks Olaf I'll try your solution
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top