Insert redords in SQL from Foxpro

I want to populate a SQL Server 2008 database table with records for test purposes. I use Foxpro 9.0 sp2 and have tried with this code, that unfortunately don't work. The Sqlexec line returns -1 and nothing is stored in the table. What am I doing wrong?

close databases all
cConnstr = 'DSN=Demo;Description=Demo;UID=myopid;' + ;
      'Trusted_Connection=Yes;APP=Microsoft Visual FoxPro;' + ;
nHnd = Sqlstringconnect(cConnstr)

for ii=1 to 100
      cAccount = Transform(Int(ii + 1000))
      cAccountName = 'Name: ' + cAccount
      ? cAccount, cAccountName
      Sqlexec(nHnd, 'insert into Trans  (Account, AccountName) values (cAccount, cAcoountName)')
      ?? Sqlcommit(nHnd)

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Put a question mark in front of cAccount and cAccountName.
Sqlexec(nHnd, 'insert into Trans  (Account, AccountName) values (?cAccount, ?cAccountName)')

In your example cAccountName is misspelled also.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Execute following command immediatelly after SQLEXEC which returns -1

? AERROR(laErr)

laErr is an array and it should contain extended error info from ODBC driver. You may display this info by:


BTW, the Sqlcommit(nHnd)  is not necessary in your case because you did not open any transaction.
The questionmark should probably help.
krhagAuthor Commented:
Thanks, I'll try this. The misspelling is a typo only here...
krhagAuthor Commented:
Thanks... I should have found it myself... but this saved lots of time :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.