Microsoft KB Archive/101742: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - ">" to ">")
 
(2 intermediate revisions by the same user not shown)
Line 45: Line 45:
== SUMMARY ==
== SUMMARY ==


To open a dBASE table file that has a non-standard file extension, specify the table name as <filename>#<extension>.
To open a dBASE table file that has a non-standard file extension, specify the table name as <filename>#<extension>.


</div>
</div>
Line 52: Line 52:
== MORE INFORMATION ==
== MORE INFORMATION ==


The standard file extension used by dBASE for tables is .DBF. In Visual Basic version 3.0 using the dBASE installable ISAMs, you can open a table by specifying the file name without this extension because the dBASE installable ISAM assumes the extension to be .DBF by default. If you specify the extension &lt;filename&gt;.&lt;extension&gt;, the dBASE installable ISAM will not recognize it and will give you the following error message:
The standard file extension used by dBASE for tables is .DBF. In Visual Basic version 3.0 using the dBASE installable ISAMs, you can open a table by specifying the file name without this extension because the dBASE installable ISAM assumes the extension to be .DBF by default. If you specify the extension <filename>.<extension>, the dBASE installable ISAM will not recognize it and will give you the following error message:
<div class="errormessage">
<div class="errormessage">


&lt;filename&gt;.&lt;extension&gt; isn't a valid name.
<filename>.<extension> isn't a valid name.


</div>
</div>
To open a dBASE table file that has a non-standard file extension, specify the table name as &lt;filename&gt;#&lt;extension&gt;. The dBASE installable ISAM interprets the pound sign (#) in the table name as a period and opens the dBASE table.
To open a dBASE table file that has a non-standard file extension, specify the table name as <filename>#<extension>. The dBASE installable ISAM interprets the pound sign (#) in the table name as a period and opens the dBASE table.
=== Example ===
=== Example ===


Line 72: Line 72:
       Dim OldAuthors As Table
       Dim OldAuthors As Table


       Connect$ = &quot;dBASE III&quot;         ' Specify database type
       Connect$ = "dBASE III"         ' Specify database type
       dbName$ = &quot;C:\DBASEIII\OLDBOOKS&quot;     ' Specify database directory
       dbName$ = "C:\DBASEIII\OLDBOOKS"     ' Specify database directory


       Set db = OpenDatabase(dbName$, False, False, Connect$)
       Set db = OpenDatabase(dbName$, False, False, Connect$)
       Set OldAuthors = db.OpenTable(&quot;Authors#Old&quot;) ' Open table
       Set OldAuthors = db.OpenTable("Authors#Old") ' Open table
       While Not OldAuthors.EOF
       While Not OldAuthors.EOF
         Print OldAuthors(0)          ' Print field(0) to the form
         Print OldAuthors(0)          ' Print field(0) to the form

Latest revision as of 10:18, 20 July 2020

Knowledge Base


How to Open dBASE Table with Nonstandard File Extension

Article ID: 101742

Article Last Modified on 10/28/2003



APPLIES TO

  • Microsoft Visual Basic 3.0 Professional Edition
  • Microsoft Visual Basic 3.0 Professional Edition



This article was previously published under Q101742

SUMMARY

To open a dBASE table file that has a non-standard file extension, specify the table name as <filename>#<extension>.

MORE INFORMATION

The standard file extension used by dBASE for tables is .DBF. In Visual Basic version 3.0 using the dBASE installable ISAMs, you can open a table by specifying the file name without this extension because the dBASE installable ISAM assumes the extension to be .DBF by default. If you specify the extension <filename>.<extension>, the dBASE installable ISAM will not recognize it and will give you the following error message:

<filename>.<extension> isn't a valid name.

To open a dBASE table file that has a non-standard file extension, specify the table name as <filename>#<extension>. The dBASE installable ISAM interprets the pound sign (#) in the table name as a period and opens the dBASE table.

Example

The following code example demonstrates how to open a dBASE table file that has a non-standard file extension (AUTHORS.OLD) and print the first field of all records in the table to the form. The following example assumes that you have a dBASE III table with a file name of AUTHORS.OLD located in the C:\DBASEIII\OLDBOOKS directory. You may need to modify the example and create a dBASE III database with a table called AUTHORS.OLD in order for it to work correctly.

  1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.
  2. Add a Command Button (Command1) to Form1.
  3. Add the following code to the Click event of Command1:

       Sub Command1_Click()
          Dim db As Database
          Dim OldAuthors As Table
    
          Connect$ = "dBASE III"          ' Specify database type
          dbName$ = "C:\DBASEIII\OLDBOOKS"      ' Specify database directory
    
          Set db = OpenDatabase(dbName$, False, False, Connect$)
          Set OldAuthors = db.OpenTable("Authors#Old") ' Open table
          While Not OldAuthors.EOF
             Print OldAuthors(0)           ' Print field(0) to the form
             OldAuthors.MoveNext           ' for all records.
          Wend
    
          OldAuthors.Close
          db.Close
       End Sub
                            
  4. Run the example.
  5. Click the Command1 button.



Additional query words: 3.00

Keywords: KB101742