Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP to Access Again
Message
De
01/05/2008 15:55:21
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Divers
Thread ID:
01314382
Message ID:
01314611
Vues:
11
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform