HOWTO: How to Disable ODBC Login Prompt at Run-Time (187720)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 3.0b
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Data Access Components 2.5

This article was previously published under Q187720

SUMMARY

Under certain circumstances, for example when the username or password is not correctly provided, an ODBC login prompt displays when connecting to an ODBC datasource. This article illustrates two ways to disable the ODBC login prompt.

MORE INFORMATION

Below are two ways to disable the login prompt when connecting to an ODBC datasource.

Using a Named Connection

  1. Create/Open a database container (for example Test.dbc).
  2. Create a dummy connection, "conn1", and specify a datasource.
  3. Leave the Userid and Password fields blank.
  4. Select Never for "Display ODBC Login Prompt".
  5. Use the following code to change the Username and Password in the named connection:
          =dbsetprop("Conn1","connection","UserID","<userid>")
          =dbsetprop("conn1","Connection","Password","<password>")
    							
  6. Now you can use the connection to connect to an ODBC DataSource without getting the Login prompt.

Using SQLStringConnect() or SQLConnect()

  1. Run the following code to set the default setting of a SQL connection:
          =SQLSetProp(0,"Displogin",3)
    							
    Setting 0 (zero) as the connection handle specifies Visual FoxPro default settings at the environment level.
  2. Now you can connect to the ODBC datasource using one of the following commands, without getting the login prompt:
          =SQLStringConnect('dsn=<Data Source>;uid=<User ID>;pwd=<Password>')
    							
    -or-
          =SQLConnect('<Data Source>', '<User ID>', '<Password>')
    							

Modification Type:MinorLast Reviewed:3/3/2005
Keywords:kbhowto KB187720