Taco
Lifetime Supporting Member
Hi there,
I have to connect to a MSSQL database. Usually I make my query using the 'FB_Formatstring' function. This works fine for normal variables. But now I have to write a DateTimeStamp to the database. I can't get it into my query using the normal 'FB_Formatstring' function. How do I get this to work?
Here's an example of my code, like I use it:
FUNCTION_BLOCK UpdateSQL
VAR_INPUT
_NetID : STRING;
_DBID : UDINT;
_SEQU : DINT;
_DTS : DT;
END_VAR
VAR_OUTPUT
..............
END_VAR
VAR
fWriteSQL : FB_DBRecordInsert;
sqlComstr : FB_Formatstring;
sqlCommand : T_MaxString;
END_VAR
sqlComstr (
sFormat:='UPDATE TABLENAME SET SEQUENTIAL=%D, DATETIME=%?? WHERE IEN=111',
arg1:= F_DINT(_SEQU),
arg2:= F_?????????? ==> here should the conversion go from datetime
);
Anyone, any idea?
Thanks,
Taco
I have to connect to a MSSQL database. Usually I make my query using the 'FB_Formatstring' function. This works fine for normal variables. But now I have to write a DateTimeStamp to the database. I can't get it into my query using the normal 'FB_Formatstring' function. How do I get this to work?
Here's an example of my code, like I use it:
FUNCTION_BLOCK UpdateSQL
VAR_INPUT
_NetID : STRING;
_DBID : UDINT;
_SEQU : DINT;
_DTS : DT;
END_VAR
VAR_OUTPUT
..............
END_VAR
VAR
fWriteSQL : FB_DBRecordInsert;
sqlComstr : FB_Formatstring;
sqlCommand : T_MaxString;
END_VAR
sqlComstr (
sFormat:='UPDATE TABLENAME SET SEQUENTIAL=%D, DATETIME=%?? WHERE IEN=111',
arg1:= F_DINT(_SEQU),
arg2:= F_?????????? ==> here should the conversion go from datetime
);
Anyone, any idea?
Thanks,
Taco