sql server programming:
Hi,
I have only two fields in table 1. Integer and 2. Image
I have application in VC++ .
I have binded the table
Now Problem is that If I use CursorLocation=adUseClient then the image
data does't not reflect in Table while adding But If I use
CursorLocation=adUseServer then it works fine. Even I created a test
application to check this problem and found the same problem.
code of test application is given below
class CEmployeeRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CEmployeeRs)
//Column empid is the 1st field in the recordset
ADO_VARIABLE_LENGTH_ENTRY2(1, adInteger, m_id,
sizeof(m_id), l_idStatus, TRUE)
ADO_VARIABLE_LENGTH_ENTRY2(2, adLongVarBinary, m_nav,
sizeof(m_nav), l_navStatus, TRUE)
END_ADO_BINDING()
public:
int m_id;
ULONG l_idStatus;
BYTE m_nav[50];
ULONG l_navStatus;
};
void CDBConversionDlg::OnButton1()
{
// TODO: Add your control notification handler code here
if (! CreateDatabaseConnection() )
{
return ;
}
try
{
_RecordsetPtr pRs=NULL;
IADORecordBinding *picRs = NULL;
CEmployeeRs emprs; //C++ class object
_variant_t vNull;
vNull.vt = VT_ERROR;
vNull.scode = DISP_E_PARAMNOTFOUND;
pRs.CreateInstance(__uuidof(Recordset));
pRs->PutRefActiveConnection(m_ConnectionPtr);
pRs->CursorLocation=adUseClient;
CString strQuery="select id,nav from Table1";
pRs->Open((LPCTSTR)strQuery, vNull, adOpenKeyset, adLockOptimistic,
adCmdText);
TESTHR(pRs->QueryInterface(__uuidof(IADORecordBinding),(LPVOID*)&picRs));
//Bind the Recordset to a C++ Class here
TESTHR(picRs->BindToRecordset(&emprs));
memset(emprs.m_nav,0,50);
memcpy(emprs.m_nav,"3",1);
TESTHR(picRs->AddNew(&emprs));
}
catch(_com_error &e)
{
MessageBox(e.Description());
MessageBox(e.ErrorMessage());
return;
}
catch(...)
{
return;
}
}
I think my query is cleared enough now to understand.