Click here to Skip to main content
15,894,017 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: ComboBox Pin
S p k 52124-Jun-10 3:38
S p k 52124-Jun-10 3:38 
AnswerRe: ComboBox Pin
Schehaider_Aymen24-Jun-10 3:47
Schehaider_Aymen24-Jun-10 3:47 
AnswerRe: ComboBox Pin
rp_suman24-Jun-10 6:50
rp_suman24-Jun-10 6:50 
QuestionAdding NM_DBLCLK message to CTreeCtrl Pin
Sakhalean24-Jun-10 2:19
Sakhalean24-Jun-10 2:19 
AnswerRe: Adding NM_DBLCLK message to CTreeCtrl Pin
Iain Clarke, Warrior Programmer24-Jun-10 19:10
Iain Clarke, Warrior Programmer24-Jun-10 19:10 
AnswerRe: Adding NM_DBLCLK message to CTreeCtrl Pin
numfive15-Jan-11 22:41
numfive15-Jan-11 22:41 
GeneralRe: Adding NM_DBLCLK message to CTreeCtrl Pin
Sakhalean16-Jan-11 17:46
Sakhalean16-Jan-11 17:46 
QuestionUnicode String in SQL Query using VC ( ADODB or CRecordset) Pin
vijay.victory24-Jun-10 2:08
vijay.victory24-Jun-10 2:08 
hi Experts,

I m developing an Application which handles a Database with Unicode values.
I have Done all the Settings to run the Unicode Program
    1. Added "_UNICODE" in Preprocessor Directives and removes "_MBCS"
    2. Entrypoint in Link tab as "wWinMainCRTStartup"

I have write following code to search Records of given Unicode value.
It runs fine but could not give any Records/Result back.
It just out of While loop.

Please Help me out..My code is as follows. :-

<code>
	CDatabase cn;
	CString FieldValue1,FieldValue2,FieldValue3;
	CDBVariant varvalue;

	CString csPwd,csUser,csServer,csDBName;
	csPwd = "SQLServer2005";
	csUser = "sa";
	csDBName = "DeccanCollege";
	csServer = "DECCANSERVER";

	cn.OpenEx(_T("DRIVER={SQL Server};Pwd="+csPwd+";Uid="+csUser +";Database="+csDBName+";Server="+csServer),CDatabase::noOdbcDialog);

	TCHAR *m_Voc = (TCHAR*) malloc(50); //allocate memory
        m_VocEdit.GetWindowText(m_Voc,50);     // get Edit box Unicode Value

//Suggest How to Pass "m_Voc" value as Unicode
	CString sqlStr = _T("Select * from Vocablemaster where slvid in(Select slvid from slipvocmaster where binno between 165 and 169) and (VocDescSan like N'%"+CString(m_Voc)+"%')");
	CRecordset rec(&cn);
	rec.Open(CRecordset::forwardOnly,sqlStr,CRecordset::none);

   while(!rec.IsEOF()) 
	{
		rec.GetFieldValue((short)0,FieldValue1);
		rec.GetFieldValue((short)1,FieldValue2);
		rec.GetFieldValue((short)2,FieldValue3); 
		rec.MoveNext();
	}
</code>



I have tried it by another way also by ADODB..
Its code is as follows :-
<code>
  HRESULT hr;
  CoInitialize(NULL);
  try
  {
	  ADODB::_ConnectionPtr connection;
	  hr = connection.CreateInstance(__uuidof(ADODB::Connection));
	  if (FAILED(hr))
	  {
		  throw _com_error(hr);
	  }
	  ADODB::_RecordsetPtr recordset;
	  hr = recordset.CreateInstance(__uuidof(ADODB::Recordset));
	  if (FAILED(hr))
	  {
		  throw _com_error(hr);
	  }
	  connection->CursorLocation = ADODB::adUseClient;
	  connection->Open(L"Provider=sqloledb;Data Source=DECCANSERVER;"
		L"Initial Catalog=DeccanCollege;User Id=sa;Password=SQLServer2005;", L"",
		L"", ADODB::adConnectUnspecified);

	  TCHAR *m_Voc = (TCHAR*) malloc(50); //allocate memory
        m_VocEdit.GetWindowText(m_Voc,50);     // get Edit box Unicode Value

        _variant_t varVoc = m_Voc;
//Suggest How to Pass "m_Voc" value as Unicode
	  recordset->Open(L"SELECT * from VocableMaster where VocNo like  N'%"+_bstr_t(varVoc.bstrVal)+"%'",  connection.GetInterfacePtr(),
			ADODB::adOpenForwardOnly, ADODB::adLockReadOnly,  ADODB::adCmdText);
	  while(!recordset->ADOEOF)	 
	  {
		  _variant_t var;
		  var = recordset->Fields->GetItem(L"VocDescSan")->GetValue();
		  std::cout << static_cast<char *>(_bstr_t(var.bstrVal))
			<< std::endl;
			  recordset->MoveNext();
	  };
	  recordset->Close();	  
  }
  catch(_com_error &e)
  {
	  //std::cerr << ::outputashex(hr) << ":"
	  std::cerr << static_cast<char *>(e.Description());
  }
  catch(...)
  {
	  std::cerr << "Unhandled Exception";
  };

</code>


Please help me out....
Thnks in advance...
Its urgent for Me..

How can I send Unicode Values through SQL Query and Get the Records..
Is there any another way or any Settings I have to do???
I have never failed,I just found 1000 ways that never works.
Regards,
Victory.

QuestionGetting value of a input attribute 'id' of a resource in a webpage Pin
Pk.j23-Jun-10 23:47
Pk.j23-Jun-10 23:47 
AnswerRe: Getting value of a input attribute 'id' of a resource in a webpage Pin
«_Superman_»24-Jun-10 0:33
professional«_Superman_»24-Jun-10 0:33 
GeneralRe: Getting value of a input attribute 'id' of a resource in a webpage Pin
Pk.j24-Jun-10 1:52
Pk.j24-Jun-10 1:52 
GeneralRe: Getting value of a input attribute 'id' of a resource in a webpage Pin
Niklas L24-Jun-10 1:57
Niklas L24-Jun-10 1:57 
QuestionRe: Getting value of a input attribute 'id' of a resource in a webpage Pin
David Crow24-Jun-10 3:03
David Crow24-Jun-10 3:03 
GeneralRe: Getting value of a input attribute 'id' of a resource in a webpage [modified] Pin
Pk.j24-Jun-10 20:12
Pk.j24-Jun-10 20:12 
QuestionElliminate the e symbol from doubles Pin
Schehaider_Aymen23-Jun-10 23:43
Schehaider_Aymen23-Jun-10 23:43 
AnswerRe: Elliminate the e symbol from doubles Pin
CPallini23-Jun-10 23:46
mveCPallini23-Jun-10 23:46 
GeneralRe: Elliminate the e symbol from doubles Pin
Schehaider_Aymen24-Jun-10 0:03
Schehaider_Aymen24-Jun-10 0:03 
GeneralRe: Elliminate the e symbol from doubles Pin
CPallini24-Jun-10 0:07
mveCPallini24-Jun-10 0:07 
GeneralRe: Elliminate the e symbol from doubles Pin
Schehaider_Aymen24-Jun-10 0:14
Schehaider_Aymen24-Jun-10 0:14 
GeneralRe: Elliminate the e symbol from doubles Pin
CPallini24-Jun-10 0:25
mveCPallini24-Jun-10 0:25 
GeneralRe: Elliminate the e symbol from doubles Pin
Schehaider_Aymen24-Jun-10 0:27
Schehaider_Aymen24-Jun-10 0:27 
GeneralRe: Elliminate the e symbol from doubles Pin
CPallini24-Jun-10 0:53
mveCPallini24-Jun-10 0:53 
AnswerRe: Elliminate the e symbol from doubles Pin
Niklas L24-Jun-10 0:02
Niklas L24-Jun-10 0:02 
GeneralRe: Elliminate the e symbol from doubles Pin
Schehaider_Aymen24-Jun-10 0:06
Schehaider_Aymen24-Jun-10 0:06 
GeneralRe: Elliminate the e symbol from doubles Pin
Niklas L24-Jun-10 0:15
Niklas L24-Jun-10 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.