Inserting null values in database through VC++ and ADO
I have some fields in database which can be null. The value for these fields come from screen and I don't know in advance whether it is going to be null or not. I want to construct SQL statement that will handle null values. In java there are parameterized queries where we can set paramater type as null for null values. How do I manage null values in VC++ and ADO.
regards,
Jatin.
# 1 Re: Inserting null values in database through VC++ and ADO
CString strNull(_T("Null"));
CString strSQL = _T("UPDATE MyTable SET FIeld1 = ");
if(<field value was set>) // check if the value was set
{
strSQL += <its value>; // some new value
}
else // not set!
{
strSQL += strNull;
}Now use the Execute with this SQL query