all groups > sql server odbc > august 2007 >
You're in the

sql server odbc

group:

SQL Server VARCHAR(MAX) column Returns error while Inserting recor


SQL Server VARCHAR(MAX) column Returns error while Inserting recor Ravi
8/22/2007 3:34:01 PM
sql server odbc:

SQL Server VARCHAR(MAX) column Returns error while Inserting records into
table(ODBC Driver: SQL Native Client)
Was this post helpful ?


I created very simple table with 3 columns and one is varchar(max) datatype

When i insert records thru VC++ ADO code i am getting this error



Exception Description Multiple-step OLE DB operation generated errors.
Check e
ach OLE DB status value, if available. No work was done. and Error Number::
-2147217887



ODBC Driver: SQL Native Client

SQL server 2005



Table

CREATE TABLE [dbo].[RAVI_TEMP](

[ID] [int] NULL,

[Name] [varchar](max) NULL,

[CITY] [varchar](50) NULL

)



VC++ code

#include "stdafx.h"
#include <string>
#include <strstream>
#include <iomanip>


int main(int argc, char* argv[])
{
try
{
HRESULT hr = CoInitialize(NULL);
_RecordsetPtr pExtRst = NULL;
_bstr_t bstrtDSN, bstrtSQL;
bstrtDSN = L"DSN=espinfo;UID=opsuser;PWD=opsuser;";
bstrtSQL = L"SELECT * FROM RAVI_TEMP";

_variant_t vartValueID,vartValueNAME,vartValueCITY;
_bstr_t bstrtValueID,bstrtValueNAME,bstrtValueCITY;

pExtRst.CreateInstance(__uuidof(Recordset));
hr = pExtRst->Open(bstrtSQL, bstrtDSN, adOpenDynamic, adLockOptimistic,
adCmdText);

hr = pExtRst->AddNew();

bstrtValueID = L"1";
vartValueID = bstrtValueID.copy();

bstrtValueNAME = L"RAVIBABUBANDARU";
vartValueNAME = bstrtValueNAME.copy();

bstrtValueCITY = L"Santa Clara";
vartValueCITY = bstrtValueCITY.copy();

pExtRst->GetFields()->GetItem(L"ID")->Value = vartValueID;
pExtRst->GetFields()->GetItem(L"NAME")->Value = vartValueNAME;
pExtRst->GetFields()->GetItem(L"CITY")->Value = vartValueCITY;
pExtRst->Update();
pExtRst->Close();

}
catch(_com_error e)
{
printf("Exception Description %s and Error Number::
%d",(LPTSTR)e.Description(),e.Error());
return e.Error();
}
return 0;
CoUninitialize();
}


if i use regular SQL ODBC driver, no error but its truncating the data



Adv Thanks for your help



Re: SQL Server VARCHAR(MAX) column Returns error while Inserting recor Russell Fields
8/23/2007 10:55:24 AM
Ravi,

There are many reasons for this error number, but with your text I find the
following in the KB.

http://support.microsoft.com/kb/269495/en-us
http://support.microsoft.com/kb/257556/en-us
http://support.microsoft.com/kb/253157/en-us
http://support.microsoft.com/kb/265263/en-us
http://support.microsoft.com/kb/819759/en-us

RLF

[quoted text, click to view]

AddThis Social Bookmark Button