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
Printable View
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
varchar(n) where n is a max string length
Bayram.
_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...
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???