Link to home
Start Free TrialLog in
Avatar of kolobok
kolobok

asked on

Ho to Create a dBase DSN in Visual Basic?

I was using Q171146 at http://www.codeguru.com/vb/links/jump.cgi?ID=347 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.

Avatar of kolobok
kolobok

ASKER

Edited text of question
Avatar of kolobok

ASKER

Adjusted points to 100
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.
ASKER CERTIFIED SOLUTION
Avatar of arcusd
arcusd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
App.Title will be the DSN

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

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

ASKER

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