CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2001
    Posts
    2,455

    adding CStrings to a database

    How do I add CStrings to fields in a record using ado. What should the field type in the database file be for this?

    Mike B


  2. #2
    Join Date
    Apr 2001
    Location
    Turkmenistan
    Posts
    674

    Re: adding CStrings to a database

    varchar(n) where n is a max string length

    Bayram.


  3. #3
    Join Date
    Sep 2001
    Location
    Nowhere
    Posts
    132

    Re: adding CStrings to a database


    _RecordsetPtr pRs;
    [...Recorset init...]

    //FieldName is your varchar/nvarchar field
    CString FieldName = "MyField";

    CString toAdd = "toto";

    //add "toto" to "MyField" Field
    pRs->GetFields()->GetItem(vChpName)->PutValue(_variant_t(toAdd));
    //... other fields
    pRs->Update();




    verify that your recordset allow update

    nb: variant initialisation for int:

    _variant_t vi;
    vi.vt = VT_I4; //or VT_I2
    vi.iVal = 2;




    hope it help

    ...addicted to cpp...

  4. #4
    Join Date
    Nov 2001
    Posts
    6

    Re: adding CStrings to a database

    I have the same problem. How if I wanna add to database with CString type more than 255 characters? It runs with fewer characters. I use SQL Server 7.0 as a backend DB engine.
    How much char is the max???


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured