Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Code Problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01564364
Message ID:
01564370
Vues:
34
>>>>Bear in mind that I haven't touched VFP in 10+ years....
>>>>
>>>>I'm writing this:
>>>>
>>>>
>>>>CLEAR
>>>>sqlProcs = CREATEOBJECT("MyStuff ")
>>>>sqlProcs.ConnectionString = "Data Source=192.168.2.5;Initial Catalog=Spares2;User Id=Kevin;Password=password1"
>>>>
>>>>LOCAL conneted as Boolean
>>>>conneted = sqlProcs.TestConnection()
>>>>
>>>>IF sqlProcs.ErrorOccured
>>>>	? sqlProcs.ErrorMessage
>>>>ELSE
>>>>	? conneted
>>>>ENDIF
>>>>
>>>>
>>>>
>>>>#DEFINE TRUE	.T.
>>>>#DEFINE FALSE	.F.
>>>>#DEFINE NEWLINE CHR(13)
>>>>
>>>>DEFINE CLASS MyStuff AS Custom
>>>>
>>>>	connectionHandle = 0;
>>>>
>>>>	ErrorMessasge = ""
>>>>	ErrorOccured = FALSE
>>>>	
>>>>	ConnectionString = ""
>>>>	PROCEDURE ConnectionString_Access()
>>>>    	RETURN This.ConnectionString 
>>>>	ENDPROC
>>>>
>>>>	PROCEDURE ConnectionString_Assign(PropValue)
>>>>    	This.ConnectionString   = PropValue
>>>>	ENDPROC
>>>>
>>>>	**********************************************************
>>>>	* Function.: TestConnection
>>>>	* Purpose..: Tests a connnection to SQL Server
>>>>	*
>>>>	**********************************************************
>>>>  	FUNCTION TestConnection() AS Boolean
>>>>
>>>>		LOCAL Connected AS Boolean
>>>>		Connected = TRUE
>>>>
>>>>		IF This.ConnectionString = "" THEN
>>>>			ErrorMessasge = "No connection string specified"
>>>>			ErrorOccured = TRUE
>>>>		ENDIF
>>>>		
>>>>		IF NOT ErrorOccured 
>>>>			SQLSETPROP(0,"DispLogin",3)
>>>>
>>>>			TRY
>>>>				connectionHandle = SQLSTRINGCONNECT(This.ConnectionString)
>>>>			CATCH TO exceptionObject
>>>>				AERROR(errorArray)
>>>>		   		ErrorMessasge = "Error " + ALLTRIwM(STR(errorArray(0))) + ". Cannot make connection." + NEWLINE + errorArray(1)
>>>>		   		ErrorOccured = TRUE
>>>>				Connected = FALSE
>>>>			ENDTRY
>>>>				   
>>>>			IF connectionHandle >0
>>>>			   = SQLDISCONNECT(connectionHandle )
>>>>			ENDIF
>>>>			
>>>>		ENDIF
>>>>		
>>>>	RETURN Connected
>>>>
>>>>
>>>>ENDDEFINE
>>>>
>>>>
>>>>When I run this, the connection string property is empty down in TestConnection
>>>>
>>>>What am I doing wrong here???
>>>
>>>Why do you need Access and Assign methods for connection? What if you comment them for now?
>>
>>It was working even before I added the Access & Assign methods. I though making it a property might make a difference.
>
>I am not sure I understand your answer. Comment these methods for now. Check the property after setting it.
>
>Also, I see there are a bunch of typos in this code, say, ErrorMessage property is misspelled. Also, try checking
>
>if this.ConnectionString =="" && double equal sign

The double == did it. Also, I had to preface the property name with "this.".

Like I said, it's been a while.

Thanks Naomi!!
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform