Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing DBF File
Message
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00292880
Message ID:
00297937
Views:
38
ok check this out. Let me know if it answers your questions. This is all UT knowledge! Its a Privilege to give it back out.
Private Sub cmdAdd_Click()
    
    'Validate the table exists
    If Dir("C:\windows\system\Q12.dbf", vbNormal) = "" Then
        'Create the table to hold our information
        Dim cn1 As New ADODB.Connection
        Dim cm1 As New ADODB.Command
        cn1.Open "Driver=Microsoft Visual Foxpro Driver;UID=;SourceType=DBF;Deleted=YES;Null=NO;SourceDB=D:\"
        cm1.ActiveConnection = cn1
        cm1.CommandType = adCmdUnknown
        ' The fields are made to be slightly cryptic:              OfficeNum   StartDate    StopDate
        cm1.CommandText = "CREATE TABLE C:\windows\system\Q12.dbf (Value1 C(7),Value2 C(10),Value3 C(10))"
        cm1.Execute
        'itnMissing = itnMissing + 1 ' Count missing tables
    End If
        
        Dim cn2 As New ADODB.Connection
        Dim cm2 As New ADODB.Command
        cn2.Open "Driver=Microsoft Visual Foxpro Driver;UID=;SourceType=DBF;Deleted=YES;Null=NO;SourceDB=D:\"
        cm2.ActiveConnection = cn2
        cm2.CommandType = adCmdUnknown
        cm2.CommandText = "DELETE FROM C:\windows\system\Q12.dbf WHERE value1 = " & Chr(39) & cboOfficeNum.List(cboOfficeNum.ListIndex) & Chr(39)
        cm2.Execute
        cm2.CommandText = "INSERT INTO C:\windows\system\Q12.dbf (Value1, Value2, Value3 )  VALUES (" & Chr(34) & cboOfficeNum.List(cboOfficeNum.ListIndex) & Chr(34) & "," & Chr(34) & txtStartDate.Text & Chr(34) & "," & Chr(34) & txtStopDate.Text & Chr(34) & ")"
        cm2.Execute
End Sub

Sub PopulateOfficeNumberCombo()
'This will Populate the Office Number listbox
    Dim strDatabasePath$, strDatabaseName$, cConnectString$ 'Declare strings
    ' Be sure under project/references that
    ' Micro$oft ActivX Data Objects 2.0 Library is selected
    Dim oData As ADODB.Recordset
        
    strDatabasePath$ = "C:\DATA"
    strDatabaseName$ = "OFFICINF"
    cConnectString = "Driver=Microsoft Visual Foxpro Driver;UID=;SourceType=DBF;Deleted=YES;Null=NO;SourceDB=" + strDatabasePath
    
    Set oData = New ADODB.Recordset
    oData.Open "SELECT * FROM " + strDatabaseName, cConnectString, adOpenStatic, adLockReadOnly
    
        While Not oData.EOF
            If Trim(oData.Fields("OFFICE_NUM")) <> "" Then
                cboOfficeNum.AddItem oData.Fields("OFFICE_NUM")
            End If
        'Debug.Print Chr(34) & oData.Fields("OFFICE_NUM") & Chr(34)
        oData.MoveNext
        Wend
    cboOfficeNum.ListIndex = 0  'display the first office in the list

End Sub
>>For NTX, you'll have to use a 3rd party driver, I used codebase (www.codebase.com)to access clipper NTX tables and it works well. They make a ODBC driver that will update NTX indexes. With VB, you can use it with ADO to access the tables.
>
>This is actually a question that I have: I use Visual FoxPro, and would like to write programs that access VFP tables in VB. I have the ODBC drivers installed, but I don't have any information to get started with ADO. Can you give (or point to) some basic examples on how to open tables and use them? I get frustrated with VB because I know how to do completex table manipulation in Fox, but I can't even begin to do simple things with VB! Thanks.
>
>Basically if you can point to how to get started, I probably can figure the bulk out, but I can't even find info in the MSDN Library. (I'm sure it's there, but the help that it provides assumes that you already know how to use it.)
>
>Thanks again.
>Ben Keene
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform