うわー..間違った方法で行っていると思います.SQLデータベースに対して単純なSQLCONNECT()を実行し、データソース、ストアドプロシージャなどに対してクエリを実行すると、VFPのカーソルになります.. . 次に、DBF に「コピー」するだけで完了です...
lnH = SQLCONNECT()
(ODBC 接続のダイアログが表示されます)。
そうでなければ、あなたはできる
lnH = SQLStringConnect("Provider=... for sql server, server name, etc")
それで
if lnH > 0
sqlexec( lnH, "select * from someTableOnServer where whateverConditon", "C_LocalCursor" )
select C_LocalCursor
copy to PermanentTable
sqldisconnect( lnH )
endif
現在、10 文字を超える列名の列があり、データベース コンテナーを使用していない場合は、列名を取得するようにクエリを変更するか、ローカルに合わせてデータを再選択して調整する必要がある場合があります。 10 文字の非 DBC テーブル コンテキストに変換します。
クエリを作成する別の例として、入力中の読みやすさのために、次のような text/endtext を使用します。
text to lcSQLCmd noshow pretext 1+2
select
t1.Column1,
t1.AVeryLongColumnName as AVLColName,
t1.AnotherLongColumn2 as ALC2,
t1.SomeFlag,
t2.ColumnFromAnotherTable as CFATbl,
t2.AnotherCol
from
SQLDatabase.dbo.SQLTable1 t1
join SQLDatabase.dbo.SQLTable2 t2
on t1.SomeKey = t2.SomeKey
where
t1.SomeCriteria = 'whatever'
order by
t1.SomeFlag
endtext
*/ Then, to "clean up" the string for VFP to pass properly,
*/ strip out the cr/lf from the text such as
lcSQLCmd = chrtran( lcSQLCmd, chr(13)+chr(10), "" )
*/ THEN, pass this command through sqlexec()
sqlexec( lnH, lcSQLCmd, "C_LocalCursor" )
2 つ目は明らかに、取得しようとしているものを読みやすくするためです。また、長い列名を VFP 10 文字の非 DBC 列名の制限に事前に短縮していることにも注意してください。次に、最初の例のようにコピーします。