这样吧,我把程序帖出来给大家看看!如果发现了问题,请提醒小弟弟我!以下是将要删除的表的信息显示在DATAGRID里面的。 On Error Resume Next
Dim Conn As New ADODB.Connection Dim Rst As New ADODB.Recordset Dim StrConn As String Dim SQLConn As String
ShowSearchResult.Visible = True 'SHOWSEARCHRESULT就是一个DATAGRID StrConn = "Provider=MSDASQL.1;Driver=Microsoft Visual Foxpro Driver;SourceDB=" & TempDBFPath & ";SourceType=DBF" SQLConn = "Select * from temp" Conn.CursorLocation = adUseClient Conn.Open StrConn Rst.Open SQLConn, Conn, adOpenStatic, adLockOptimistic If Err.Number = -2147217865 Then GoTo ErrorHandle End If If Not Rst.EOF Then Set ShowSearchResult.DataSource = Rst ShowSearchResult.Refresh Dim i As Integer ReDim FieldName(Rst.Fields.Count) Else ShowSearchResult.Visible = False End If 下面的程序是将这个数据表文件删除用的。 If Rst.State = 1 Then Rst.Close End If If Conn.State = 1 Then Conn.Close Set Conn = Nothing End If If Dir(TempDBFPath + "\temp.dbf") <> "" Then Set ShowSearchResult.DataSource = Nothing DoEvents DeleteFile(Temp) '这里是调用的API End If If Dir(TempDBFPath + "\temp2.dbf") <> "" Then Set ShowSearchResult.DataSource = Nothing DoEvents DeleteFile(Temp) '这里是调用的API End If请大家帮帮我!谢谢!
刚才删除的那段写错了. If Rst.State = 1 Then Rst.Close End If If Conn.State = 1 Then Conn.Close Set Conn = Nothing End If If Dir(TempDBFPath + "\temp.dbf") <> "" Then Set ShowSearchResult.DataSource = Nothing DoEvents DeleteFile(TempDBFPath + "\temp.dbf") '这里是调用的API End If If Dir(TempDBFPath + "\temp2.dbf") <> "" Then Set ShowSearchResult.DataSource = Nothing DoEvents DeleteFile(TempDBFPath + "\temp2.dbf") '这里是调用的API End If
而不能运行的那太机器是P4 1.5G的。真是郁闷啊!请大家帮帮我!
建议在该语句设一个断点,然后运行至该语句前,用手工删一下。
一般把这样的数据库文件和工程文件都放在一个工程文件夹里,然后路径就是
“app.path & temp.dbf”
Dim Conn As New ADODB.Connection
Dim Rst As New ADODB.Recordset
Dim StrConn As String
Dim SQLConn As String
ShowSearchResult.Visible = True 'SHOWSEARCHRESULT就是一个DATAGRID
StrConn = "Provider=MSDASQL.1;Driver=Microsoft Visual Foxpro Driver;SourceDB=" & TempDBFPath & ";SourceType=DBF"
SQLConn = "Select * from temp"
Conn.CursorLocation = adUseClient
Conn.Open StrConn
Rst.Open SQLConn, Conn, adOpenStatic, adLockOptimistic
If Err.Number = -2147217865 Then
GoTo ErrorHandle
End If
If Not Rst.EOF Then
Set ShowSearchResult.DataSource = Rst
ShowSearchResult.Refresh
Dim i As Integer
ReDim FieldName(Rst.Fields.Count)
Else
ShowSearchResult.Visible = False
End If
下面的程序是将这个数据表文件删除用的。
If Rst.State = 1 Then
Rst.Close
End If
If Conn.State = 1 Then
Conn.Close
Set Conn = Nothing
End If
If Dir(TempDBFPath + "\temp.dbf") <> "" Then
Set ShowSearchResult.DataSource = Nothing
DoEvents
DeleteFile(Temp) '这里是调用的API
End If
If Dir(TempDBFPath + "\temp2.dbf") <> "" Then
Set ShowSearchResult.DataSource = Nothing
DoEvents
DeleteFile(Temp) '这里是调用的API
End If请大家帮帮我!谢谢!
If Rst.State = 1 Then
Rst.Close
End If
If Conn.State = 1 Then
Conn.Close
Set Conn = Nothing
End If
If Dir(TempDBFPath + "\temp.dbf") <> "" Then
Set ShowSearchResult.DataSource = Nothing
DoEvents
DeleteFile(TempDBFPath + "\temp.dbf") '这里是调用的API
End If
If Dir(TempDBFPath + "\temp2.dbf") <> "" Then
Set ShowSearchResult.DataSource = Nothing
DoEvents
DeleteFile(TempDBFPath + "\temp2.dbf") '这里是调用的API
End If