Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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>')
    							

↑ Back to the top


Keywords: KB187720, kbhowto

↑ Back to the top

Article Info
Article ID : 187720
Revision : 4
Created on : 3/3/2005
Published on : 3/3/2005
Exists online : False
Views : 490