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.

Syntax

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

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

Password
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.

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

VBScript

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

JavaScript

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

C#

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

VB.NET

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

See also

Users Collection