krhag
asked on
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
clear
cConnstr = 'DSN=Demo;Description=Demo ;UID=myopi d;' + ;
'Trusted_Connection=Yes;AP P=Microsof t Visual FoxPro;' + ;
'WSID=MYPCNAME;DATABASE=De mo;'
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)
next
Sqldisconnect(nHnd)
close databases all
clear
cConnstr = 'DSN=Demo;Description=Demo
'Trusted_Connection=Yes;AP
'WSID=MYPCNAME;DATABASE=De
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)
next
Sqldisconnect(nHnd)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The questionmark should probably help.
ASKER
Thanks, I'll try this. The misspelling is a typo only here...
ASKER
Thanks... I should have found it myself... but this saved lots of time :)