Mike Yearwood
Toronto, Ontario, Canada
General information
Category:
Coding, syntax & commands
Hi Julie
>I run this code at work and it has no errors. When I run it at home I get a parameter screen popup when the insert command runs and when I take the question marks out I get a 'connectivity error(ODBC Microsoft Access Driver) too few parameters...4 expected'
>
>What do I need to look for in differences in both. I run vfp 9 in both places. SP1 at home, SP2 at work and Access 2002 home and Access 2003 at work.
I'm not expert in Access, but you should continue to use the question marks. That makes the values parameters. Concatenating user content into SQL commands is the classic newbie mistake that leads to SQL Injection Attacks.
>
>
>*******
>lnHandle = sqlstringconnect('Driver=Microsoft Access Driver (*.mdb);' + ;
> 'dbq=H:\Source Code\Access Test\db1.mdb')
>IF lnHandle < 1
> AERROR(laError)
> MESSAGEBOX(laError[1,2])
> RETURN
>ENDIF
>USE table1 &&& Fox Table with same stucture
>SCAN
> cAccid=table1.accid
> cAccountnum=table1.accountnum
> cAccountNam=table1.accountnam
> cPswd=table1.pswd
> lnResult = SQLEXEC(lnHandle, 'INSERT INTO accounts ' + ;
> '(accid, accountnumber, accountname, pswd)' + ;
> 'VALUES (?cAccid, ?cAccountnum, ?cAccountNam, ?cPswd)')
>
> IF lnResult < 1
> AERROR(laError)
> MESSAGEBOX(laError[1,2])
> RETURN
> ENDIF
>ENDSCAN
>USE
>SQLDISCONNECT(lnHandle)
>RETURN
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only