Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server ODBC driver error message 1

Status
Not open for further replies.

selinis

Programmer
Oct 15, 2001
29
CA
Hi!
Does anyone know how can I avoid displaying an SQL Server ODBC driver error message: "Connection failed/SQL State:28000/SQL SErver Error:18456/...login failed for user..".
I'm trying to store a connection handle into a variable using STORE SQLCONNECT TO variable;the code sequence which is treating the result (positive or negative handle)is active AFTER the message above.
thanks a lot!
 
If you post the code we could probably help. In the meantime here is the code I use in my sql server logon form.

Please note: I have found this only works properly if you set the 'Display ODBC login prompts' property to NEVER.

Also this is a small piece of the code it assumes the various variables have already been set.

ccon = 'DRIVER=sql server;SERVER='+cserver+;
';DATABASE='+cdatabase+;
';UID='+alltrim(thisform.txtusername.value)+;
';PWD='+alltrim(thisform.txtpassword.value)+;
';APP='+gcprogname
dbsetprop('csql','connection','connectstring',ccon)
NCON = SQLCONNECT('csql')
IF NCON < 1
thisform.ntrys = thisform.ntrys + 1
nPosition=At(&quot;Server]&quot;,message())
cMessage = substr(message(), nPosition+7)
if thisform.ntrys = 3
cmessage = cmessage + chr(13) + ;
'Your login has failed 3 times.'+chr(13) +;
'Please contact your system administrator'
endif
WAIT WINDOW cmessage
if thisform.ntrys = 3
thisform.nreturnvalue = -1
thisform.release
else
thisform.txtusername.setfocus
endif
ELSE
SQLDISCONNECT(NCON)
DODEFAULT()
ENDIF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top