参考FoxPro的代码 Dim FoxFreeDB As Database Dim FoxFreeRS As Recordset Set FoxFreeDB = Workspaces(0).OpenDatabase("C:\VFP", False, _ False, "FoxPro 3.0;") Set FoxFreeRS = FoxFreeDB.OpenRecordset("Foxuser") Set Data1.Recordset = FoxFreeRSC:\VFP是目录,Foxuser是表
多谢呆瓜和泰山的帮忙。 问呆瓜:如果我建立foxbase表,在你程序的以下两个地方应该怎么写。 Set dat = OpenDatabase(App.Path & "\", False, False, "FoxPro 2.5") CommonDialog1.Filter = "FoxPro 2.5 Files (*.dbf)¦*.dbf"
只要生成后缀为dbf的表就可以了。
http://www.csdn.net/expert/topic/494/494209.shtm
领分,至少100
Dim r As New ADODB.Recordset
Set dat = OpenDatabase(App.Path & "\", False, False, "FoxPro 2.5")' 设置“CancelError”为 True
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' 设置标志
'CommonDialog1.Flags = cdlOFNHideReadOnly
' 设置过滤器
CommonDialog1.Filter = "FoxPro 2.5 Files (*.dbf)|*.dbf"
' 指定缺省的过滤器
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowSave
On Error GoTo 0
dat.Execute "delete from pztemp"
ListView1.Refresh
For i = 1 To ListView1.ListItems.Count
SQL = "insert into Pztemp("
SQL = SQL & "pzbh,kmdm,rq,zyxx,jd,lc,je) "
SQL = SQL & "values('"
SQL = SQL & Trim(ListView1.ListItems(i).Text) & "','"
SQL = SQL & Trim(ListView1.ListItems(i).SubItems(1)) & "','"
SQL = SQL & Format(Trim(ListView1.ListItems(i).SubItems(2)), "yyyy-MM-dd") & "','"
SQL = SQL & Trim(ListView1.ListItems(i).SubItems(3)) & "','"
SQL = SQL & Trim(ListView1.ListItems(i).SubItems(4)) & "',"
If Not Trim(ListView1.ListItems(i).SubItems(5)) = "" Then
r.Open "select dm from lc_set where lc='" & ListView1.ListItems(i).SubItems(5) & "' and jd='" & Trim(ListView1.ListItems(i).SubItems(4)) & "'", Cn
SQL = SQL & r!dm & ","
r.Close
Else
SQL = SQL & "0,"
End If
SQL = SQL & ListView1.ListItems(i).SubItems(6) & ")"
dat.Execute SQL
next
Dim FoxFreeDB As Database
Dim FoxFreeRS As Recordset
Set FoxFreeDB = Workspaces(0).OpenDatabase("C:\VFP", False, _
False, "FoxPro 3.0;")
Set FoxFreeRS = FoxFreeDB.OpenRecordset("Foxuser")
Set Data1.Recordset = FoxFreeRSC:\VFP是目录,Foxuser是表
问呆瓜:如果我建立foxbase表,在你程序的以下两个地方应该怎么写。
Set dat = OpenDatabase(App.Path & "\", False, False, "FoxPro 2.5")
CommonDialog1.Filter = "FoxPro 2.5 Files (*.dbf)¦*.dbf"
Set tabledef = database.CreateTableDef (name, attributes, source, connect)具体不太用的, 不是很熟悉, 你也可以用SQL语句来建表呀