VFP 9 SP2
SQL server 2012 (express) backend.
Very new to SQL integration (though I know little of sql)
Little background:
App written in vfp, currently uses vfp backend data.
I am in the process of re-writing the app so it will use sql back end instead.
I am using a modified sql wrapper from west-wind. Very nice class, works well.
In many of my forms or prgs, i tend to use seek() to find certain values before other codes executes.
So, I wrote this little SQLSeek() method that, for now, seems like its giving me what i want.
My question:
How do you normally handle the equivalent of seek() in vfp, but, now in sql?
is this a bad way of "seeking"? what is the file table was really large now?
Ali Koumaiha
TeknoSoft Inc.
Michigan
SQL server 2012 (express) backend.
Very new to SQL integration (though I know little of sql)
Little background:
App written in vfp, currently uses vfp backend data.
I am in the process of re-writing the app so it will use sql back end instead.
I am using a modified sql wrapper from west-wind. Very nice class, works well.
In many of my forms or prgs, i tend to use seek() to find certain values before other codes executes.
So, I wrote this little SQLSeek() method that, for now, seems like its giving me what i want.
Code:
FUNCTION SQLSeek(tcField,tcValue,tcTable)
LOCAL lcCursor, lnCount, lcSQL
lcCursor = SYS(2015)
IF PCOUNT()< 3
MESSAGEBOX("Error in SQL Seek Method." + CHR(13) + ;
"Method requires 3 parameters.",16,"SQL Seek Error")
RETURN .f.
ENDIF
IF TYPE('tcValue') = 'C'
tcValue = [']+tcValue+[']
ENDIF
IF TYPE('loSQL') <> "O"
loSQL = createfactory("EzCellSQL")
ENDIF
TEXT TO lcSQL TEXTMERGE NOSHOW
SELECT TOP 1 <<tcField>> as RecFound FROM <<tcTable>> where <<tcField>> = <<tcValue>> order BY <<tcField>>
ENDTEXT
losql.execute(lcsql,lcCursor)
IF !empty(losql.cErrorMsg)
MESSAGEBOX("Error in SQL Seek Method." + CHR(13) + ;
"Error: " + loSQL.cErrorMsg,16,"SQL Seek Error")
RETURN .f.
ENDIF
IF USED(lcCursor)
SELECT (lcCursor)
LOCATE
lnCount = RECCOUNT(lcCursor)
USE IN SELECT(lcCursor)
RETURN IIF(lnCount>0,.t.,.f.)
ELSE
RETURN .f.
ENDIF
ENDFUNC
My question:
How do you normally handle the equivalent of seek() in vfp, but, now in sql?
is this a bad way of "seeking"? what is the file table was really large now?
Ali Koumaiha
TeknoSoft Inc.
Michigan