The Login method attempts to log into Stonefield Query as a specific user. If you successfully log in programmatically, the Login dialog won't appear for the user. This is useful if the user is already logged into the target application or if you want to automatically log the user in using their network ID.


Login(UserName as String, Password as String) as Boolean

The name of the user to log in as (case-insensitive).

The password for the user (case-insensitive).

Return Value
True if the log in was successful. The reasons it may fail are:

  • The user name does not exist in the list of authorized users.

  • The password is not the correct one for the user.

  • Someone else has logged in with this user name.

  • The number of concurrent licenses has been exceeded.

The ErrorMessage property contains the text of the reason for failure.

This example, which could be used as the code for the Application.BeforeLogin script for a project, logs the user in using their network ID (this code assumes the password is the same as the user name).

Visual FoxPro

lparameters toApplication as SQApplication
local loWSH, lcUser
loWSH = createobject('WScript.Network')
lcUser = loWSH.UserName
toApplication.Users.Login(lcUser, lcUser)


function Main(Application)
dim WshNetwork
set WshNetwork = CreateObject("WScript.Network")
UserName = WshNetwork.UserName
Application.Users.Login(UserName, UserName)
end function


function Main(Application) {
var WshNetwork ;
WshNetwork = new ActiveXObject('WScript.Network') ;
UserName = WshNetwork.UserName ;
Application.Users.Login(UserName, UserName) ;


public static bool Application_BeforeLogin(SFQApplication sfqApplication)
  return sfqApplication.Users.Login(Environment.UserName, Environment.UserName);


public shared function Application_BeforeLogin(sfqApplication as SFQApplication)
    as Boolean
  return sfqApplication.Users.Login(Environment.UserName, Environment.UserName)
End Function

See also

Users Collection

© Stonefield Software Inc., 2023 • Updated: 09/24/21
Comment or report problem with topic