Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
i getthis error Multiple-step OLE DB operation generated errors when i use distinct or group by in my query.
i dont know how to risolve.
i tride to chenge connection string but nothing
here is my code ( i am using VS 2019 - mfc c++)

LPCOLESTR hh;
	hh = L"yy";
	BSTR bstr = NULL;
	CString str, strDBcorr,strDBcorr1;
	LPCOLESTR strDBCor;
	HRESULT hrCorr, hr;
	bstr = strDBcorr.AllocSysString();
	strDBCor = bstr;
	strDBCor = _T("Provider=MSOLEDBSQL; Data Source=aaa\\SQLEXPRESS;Initial Catalog=Tag21;User ID=sa;Password=xx;");

	hrCorr = dsdbCorr.OpenFromInitializationString(strDBCor);
	SysFreeString(bstr);
	if (SUCCEEDED(hrCorr))
	{
		TRY
		{
			hr = m_sisDBTag.Open(dsdbCorr);
		}
		CATCH(CException, e)
		{

		}
		END_CATCH
String SqlProv;

	SqlProv = _T("SELECT DISTINCT Field_1 FROM Table_1;");
	TRY
	{
		CDBPropSet propset2(DBPROPSET_ROWSET);
	    propset2.AddProperty(DBPROP_IRowsetChange, true)
		propset2.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_INSERT | DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_DELETE)
CCommand<CManualAccessor,CRowset> rsss;
		
		if (rsss.Open(m_sisDBTag, SqlProv, &propset2, NULL, DBGUID_DBSQL, TRUE) != S_OK)
		{
here i get the error 
...


thanks in advance

What I have tried:

in sql server i dont have problems to excute the query
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900