Ho to Create a dBase DSN in Visual Basic?

Posted on 1999-01-20
Last Modified: 2013-11-24
I was using Q171146 at as an example creating my dBase DNS. I set a driver to
strDriver = "Microsoft dBase Driver (*.dbf)",
provided attrributes and hWnd as a parameters for the API function from ODBCJT32.DLL:
intRet = ConfigDSN(hWnd,ODBC_REMOVE_DSN,strDriver, strAttributes)
I was surprized when instead of "ODBC dBase Setup" dialog "ODBC Microsoft Access 97 Setup" dialog appeared. I tried to set it to a different drivers but it alvays displayed  "ODBC Microsoft Access 97 Setup" dialog. What wrong did I do? Maybe I set wrong attributes? What are the attributes for dBase driver anyway, where to fing them?
An example would be appreciated very much.

Question by:kolobok
  • 3
  • 2

Author Comment

ID: 1026313
Edited text of question

Author Comment

ID: 1026314
Adjusted points to 100

Expert Comment

ID: 1026315
Unless you want to remove an existing DSN you should't use ODBC_REMOVE_DSN.  As i understand you want to create a new DSN so specify ODBC_ADD_DSN instead.

Hope it helps.
Best regards.
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!


Accepted Solution

arcusd earned 100 total points
ID: 1026316
'try this code

 strAttribs = "Description=" + "  DataSource" _
          + Chr$(13) + "DBQ=" + "Test.dbf"

   rdoEngine.rdoRegisterDataSource App.Title, _
               "Microsoft dBase Driver (*.dbf)", True, strAttribs


Expert Comment

ID: 1026317
App.Title will be the DSN

strAttribs = "Description=" + "  DataSource" _
             + Chr$(13) + "DBQ=" + "Test.dbf"

rdoEngine.rdoRegisterDataSource "TEST", _
                  "Microsoft dBase Driver (*.dbf)", True, strAttribs

Author Comment

ID: 1026318
ODBC_REMOVE_DSN was just mistyping. I used ODBC_ADD_DSN.
But anyway I was sujjested using different function
SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver, strAttributes) and it worked perfectly with the same attributes and parameters.

strDriver = "Microsoft dBase Driver (*.dbf)"
    'Set the attributes delimited by null.
    strAttributes = "DSN=" & strDSN & Chr$(0)
    strAttributes = strAttributes & "DefaultDir=" & strDefDir & Chr$(0)
    strAttributes = strAttributes & "DESCRIPTION=" & strDescr & Chr$(0)
    intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver, strAttributes)

Thank you for your help

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unrecognized Database Format 8 122
SQL Server memory sizing - reallocation 16 78
Saving excel document in lotus script 4 45
Import text from rows into columns? 12 44
This article describes some very basic things about SQL Server filegroups.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question