Help me about update null value to non_value in ado vc++

Help me about update null value to non_value in ado vc++

Post by Bill Su » Thu, 24 Jan 2002 22:37:29



Hi, Anybody

   I have a hardly question that take me a lot of time. I have a Null is
able field which may have a NULL value, I hope can update this field when it
is NULL value and I look a lot of example include the MSDN provided, but no
answer can do it. In the ADO VC++ when update a field value which current is
null Value with a non_null value, it not responds error but also not make
any updating(if current have a non_null value then updating is success).
following the MSDN: PRB: MFC DB Classes Don't Update NULL Field Values to
Non-NULL,said CRecordSet before version 2.0 there are the same problem, If
whether ADO  also have the same question? I don't know? would you like give
me more instruction about null field updating?

Thank you anyway,

Bill Sun

The code is:

        m_strConnection = _T("Provider=MSDASQL.1;Persist Security
Info=False;User ID=sa;Data             Source=LocalServer;Initial
Catalog=pubs");
         m_strCmdText = _T("test");

     m_pRs->CursorLocation = adUseClient;
      m_pRs->LockType = adLockOptimistic;
      m_pRs->Open((LPCTSTR)m_strCmdText, (LPCTSTR)m_strConnection,
adOpenStatic,
       adLockOptimistic, adCmdTableDirect);
      if (FAILED(hr = m_pRs->QueryInterface(__uuidof(IADORecordBinding),
(LPVOID *)                        &piAdoRecordBinding)))
       _com_issue_error(hr);
      if (FAILED(hr = piAdoRecordBinding->BindToRecordset(this)))
           _com_issue_error(hr);

   ....
  strcpy(m_szau_fname,m_strDlgau_fname);
  m_pRs->Fields->GetItem("au_fname")->Value=(_bstr_t) m_szau_fname;
  piAdoRecordBinding->Update(this);
  m_pRs->UpdateBatch(adAffectAll);

 
 
 

Help me about update null value to non_value in ado vc++

Post by Paul » Fri, 25 Jan 2002 04:44:46


This seems to be an on-going issue. If I were you, I would
still let that field having Null enabled but set the
default value = ('') for SQL Server or "" for Access. By
doing that, you don't have to worry about updating the
NULL Field any more!

Hope it'll help

Paul

Quote:>-----Original Message-----
>Hi, Anybody

>   I have a hardly question that take me a lot of time. I
have a Null is
>able field which may have a NULL value, I hope can update
this field when it
>is NULL value and I look a lot of example include the

MSDN provided, but no
Quote:>answer can do it. In the ADO VC++ when update a field

value which current is
Quote:>null Value with a non_null value, it not responds error
but also not make
>any updating(if current have a non_null value then

updating is success).
Quote:>following the MSDN: PRB: MFC DB Classes Don't Update NULL
Field Values to
>Non-NULL,said CRecordSet before version 2.0 there are the
same problem, If
>whether ADO  also have the same question? I don't know?
would you like give
>me more instruction about null field updating?

>Thank you anyway,

>Bill Sun

>The code is:

>        m_strConnection = _T("Provider=MSDASQL.1;Persist
Security
>Info=False;User ID=sa;Data            

Source=LocalServer;Initial
Quote:>Catalog=pubs");
>         m_strCmdText = _T("test");

>     m_pRs->CursorLocation = adUseClient;
>      m_pRs->LockType = adLockOptimistic;
>      m_pRs->Open((LPCTSTR)m_strCmdText, (LPCTSTR)
m_strConnection,
>adOpenStatic,
>       adLockOptimistic, adCmdTableDirect);
>      if (FAILED(hr = m_pRs->QueryInterface(__uuidof

(IADORecordBinding),

- Show quoted text -

Quote:>(LPVOID *)                        &piAdoRecordBinding)))
>       _com_issue_error(hr);
>      if (FAILED(hr = piAdoRecordBinding->BindToRecordset
(this)))
>           _com_issue_error(hr);

>   ....
>  strcpy(m_szau_fname,m_strDlgau_fname);
>  m_pRs->Fields->GetItem("au_fname")->Value=(_bstr_t)
m_szau_fname;
>  piAdoRecordBinding->Update(this);
>  m_pRs->UpdateBatch(adAffectAll);

>.


 
 
 

Help me about update null value to non_value in ado vc++

Post by Bill Su » Fri, 25 Jan 2002 10:32:28


Hi, Paul
     Thank you recommend, I think i must work on a database designed by
other, which need me write a program
to can edit old record. the old record have some field value is null. and
must can reinput the new value. It seem have some method to input the
non-null value to nulled field. If you know, can you tell me?

thank you any way,

Bill Sun



Quote:> This seems to be an on-going issue. If I were you, I would
> still let that field having Null enabled but set the
> default value = ('') for SQL Server or "" for Access. By
> doing that, you don't have to worry about updating the
> NULL Field any more!

> Hope it'll help

> Paul

 
 
 

1. Storing date/time value on SQL server with milliseconds resolution using vc++ and ado 2.0

I am using ADO 2.0 with VC++ 5.0
My problem is that I need a way to store a date/time value in a SQL Server
6.5 database having a resolution of milliseconds.

I am using variants to send a date value to the database.
I think the milliseconds are lost using the following conversion functions.
(SystemTimeToVariantTime()).
So I tested the reverse function ( VariantTimeToSystemTime()). And Surely
the
milliseconds value was missing.

Can anyone suggest me another approach to solve my problem. I am still
inclined to use ADO objects.

SYSTEMTIME asys, bsys;
double d;
CTime t = CTime::GetCurrentTime();

        asys.wYear = t.GetYear();
        asys.wMonth = t.GetMonth();
        asys.wDayOfWeek = t.GetDayOfWeek() - 1;
        asys.wDay = t.GetDay();
        asys.wHour = t.GetHour();
        asys.wMinute = t.GetMinute();
        asys.wSecond = t.GetSecond();
        asys.wMilliseconds = 300;

        SystemTimeToVariantTime( &asys , &d);

// converting the variant back  

        VariantTimeToSystemTime(d, &bsys);

// bsys had the milliseconds missing.

2. Return Identity Value

3. Help: Vc++ ADO CADORecordBinding

4. Mac version of plug-in does not work with Filemaker 6

5. How to update the field with nullable in ADO of VC++6.0

6. Install Both Ms-sql and oracle server

7. how to update column with null value by a new value

8. Set password in data control

9. Help: UPDATE CLOB w/ NULL value errors

10. Who can tell me wy can't update NULL field valuse to non-NULL in VC==6.0 and ADO

11. Help: Inserting null values into Jet database using ADO

12. no value returned calling stored procedures in vc++

13. HELP! Capturing Ado Events in VC