when SQL Server is installed by default, the TEXT, NTEXT, and Image type fields have a length limit, and if you write more data than the limit throws an exception, the default length limit is 65536 and you need to modify the global configuration parameters of the database:
exec sp_configure ' max text repl size (B) ', ' 655360 '--adjustment length limit of 655360, increase 10 times times
reconfigure--make configuration effective
string objdata;
....... (The preparation of objdata data is omitted)
//Build a secure array
Const LONG Lweishu = 1;//safe array dimension
BYTE *pbyte;
SAFEARRAY far* PSA;
Safearraybound Rgsabound[lweishu];
rgsabound[0].llbound = 0;
rgsabound[0].celements = Objdata.length ();
PSA = SafeArrayCreate (VT_UI1, Lweishu, rgsabound);
if (Safearrayaccessdata (PSA, (void * *) &pbyte) = = NOERROR)
{
//Copy object data into a safe array
memcpy (Pbyte,&objdata[0],objdata.length ());
}
safearrayunaccessdata (PSA);
VARIANT Vararray;
VARARRAY.VT = Vt_array | VT_UI1;
vararray.parray = PSA;
//Update the data to the database.
fieldptr fieptr = Objrcrecordset->fields->getitem (_variant_t ("FieldName"));
Fieptr->appendchunk (vararray);
variantclear (&vararray);
///////////////////////////////////////////////////////////////
The above is available in the case of AddNew.
if the parameter of the stored procedure has text, image, and so on. The following section of the above code is changed to
storeprocparamobj->value = Vararray;
/////////////////////////////////////////////////////////////
also
You can use the _variant_t object instead of directly using the VARIANT structure, which automatically releases the data at the time of destruction. The latter requires
call VariantClear yourself to clean up.
The above code applies to text, the Image field type, and is tested. (ADO, VC6, Win2000, sqlserver2000)
---------------------------------------------------------------------------
Ikon Digital http://shop108303530.taobao.com
JQZCSBZ
Source:http://www.cnblogs.com/ZengSir/
email:763754930@qq. com
QQ Communication:763754930
More information, it tips, incurable diseases and so on can pay attention to the Ikon of the public number.
To resolve the length limit for the text, image type fields of SQL Server