TonyScarpelli
Programmer
I'm trying to insert a row into a SQL Server table using the SQLEXEC command, something like this:
* Create the Insert command using built string
lcStr = "INSERT INTO MyTable ("
lcStr = lcStr + "WONUM,ID,TEXTFIELD,NUMERICFIELD)"
lcStr = lcStr + "VALUES ('"
lcStr = lcStr + lcWoNum + "','"
lcStr = lcStr + lcTextField + "'," + lnNumField + ")"
* Insert into SQL table
lnErr=SQLEXEC(gnConnHandle, lcStr)
If the lnNumField field is .NULL., I need the lnNumField to be represented by a string, something like this:
IF ISNULL(NUMERICFIELD)
lnNumField = ""
ELSE
lnNumField = STR(NUMERICFIELD,9,2)
ENDIF
However, this is giving me an SQL error, because the SQL table doesn't like an empty string where a number should be, but I need a string to create the string.
Can anyone tell me how to format a .NULL. into a string?
Thanks.
Tony Scarpelli
Clinical Engineering Dept.
Maine Medical Center
Portland, Maine 04102
* Create the Insert command using built string
lcStr = "INSERT INTO MyTable ("
lcStr = lcStr + "WONUM,ID,TEXTFIELD,NUMERICFIELD)"
lcStr = lcStr + "VALUES ('"
lcStr = lcStr + lcWoNum + "','"
lcStr = lcStr + lcTextField + "'," + lnNumField + ")"
* Insert into SQL table
lnErr=SQLEXEC(gnConnHandle, lcStr)
If the lnNumField field is .NULL., I need the lnNumField to be represented by a string, something like this:
IF ISNULL(NUMERICFIELD)
lnNumField = ""
ELSE
lnNumField = STR(NUMERICFIELD,9,2)
ENDIF
However, this is giving me an SQL error, because the SQL table doesn't like an empty string where a number should be, but I need a string to create the string.
Can anyone tell me how to format a .NULL. into a string?
Thanks.
Tony Scarpelli
Clinical Engineering Dept.
Maine Medical Center
Portland, Maine 04102