Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sqlexec from vfp fails
Message
 
 
À
19/05/2016 11:22:56
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01636625
Message ID:
01636629
Vues:
58
Here is a piece of code from one of my error handling routines
LOCAL ARRAY laError[1]
LOCAL lcErrMsg

lcErrMsg = ""

=AERROR(laError)


IF laError[1,1] <> 1526
	* It's not ODBC Error
	lcErrMsg = lcErrMsg + "VFP ERROR: " + Transform(laError[1,1]) + " " + Transform(laError[1,2])
ELSE
	IF ISNULL(laError[1,3])
		lcErrMsg = lcErrMsg + ALLTRIM(laError[1,2])
	ELSE
		lcErrMsg = lcErrMsg + ALLTRIM(laError[1,3])
	ENDIF	
ENDIF	
>I need to get some data out of SQLserver from my vfp9sp2 app
>i have never done this btw
>here is what i got from the sql guy:
>
>declare @StartDate datetime , @EndDate datetime
>set @StartDate = '4/1/2016' set @EndDate = '4/30/2016'
>
>select a.*
>from BAI.F_Transaction a
>join dbo.D_Date b on ( a.GroupAsOfDate = b.RowID )
>where  ( DTransactionID = 1018 )
>             and
>             ( b.[Date] >= @StartDate and b.[Date] <= @EndDate )
>order by a.GroupAsOfDate desc
>
>
>
>here is my vfp translation
>
>
>dt1 = DATE(2016,4,1)
>dt2	= GOMONTH(dt1,1)-1
>
>
>lcServer = [OTT-sqlprod]
>
>
>CONNSTR = [Driver={SQL Server};Server=]+lcServer+[;Trusted_connection=Yes;Database=cmdw;]
>
>lnHandle = SQLSTRINGCONNECT( CONNSTR )
>*** returns 1
>
>IF Handle < 1
>	STRTOFILE( "Unable TO CONNECT TO SQL" + CHR(13) + CONNSTR, 16 )
>	RETURN
>ENDIF
>
>
>TEXT TO lcCMD NOSHOW TEXTMERGE
>select a.*
>from BAI.F_Transaction a
>join dbo.D_Date b on ( a.GroupAsOfDate = b.RowID )
>where  ( DTransactionID = 1018 )
>             and
>             ( b.[Date] >= '<<dt1>>' and b.[Date] <= '<<dt2>>' )
>order by a.GroupAsOfDate desc
>ENDTEXT
>
>
>
>lnSuccess returns -1
>
>what am I doing wrong
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform