Home > Software engineering >  VC Combo box controls how to realize the dynamic binding database?
VC Combo box controls how to realize the dynamic binding database?

Time:11-02

RT. I recently doing a little thing, which use the combo box control, control the data inside the data items need to be from a table in the database a field below the content of the dynamic increase and decrease, the younger brother way, hope the great god gives support, hope to detail, haven't done under VC examples of dynamic binding, 20904027 @qq.com

CodePudding user response:

Access to the database query the corresponding data, and then update the combobox control data, no way of dynamic binding

CodePudding user response:

Every time can only query

CodePudding user response:

Reference
access database query out the corresponding data, and then update the combobox control data, there is no way of dynamic binding

Done!

Thank you two upstairs, ask another question, the code is as follows:
 void CAddDlg: : OnSelchangeCombo1 () 
{
Cstrings STR, temp;
M_combo1. GetWindowText (STR);
//MessageBox (STR);

Temp. The Format (_T (" select installation package file name from the main table where the customer name=% s "), STR);

//MessageBox (temp);


USES_CONVERSION;
: : CoInitialize (NULL);
_ConnectionPtr con (__uuidof (Connection));//create a linked object
_RecordsetPtr RST (__uuidof (you));//create a recordset
_CommandPtr CMD (__uuidof (Command));//create the COMMAND object
Con - & gt; Open (" Data Source=ClientMessage; UID=sa; The PWD=sa;" , ""," ", adModeUnknown);
RST - & gt; Open (_variant_t (temp), _variant_t (con) (IDispatch *), adOpenDynamic, adLockOptimistic, 1);

while (! RST - & gt; AdoEOF)
{
M_combo2. AddString (W2A (RST - & gt; GetCollect (_variant_t (" installer file name ")). BstrVal));//(LPCTSTR) (_bstr_t)
RST - & gt; MoveNext ();
}

}

Error is as follows:


Warrior trouble again to see, learn,

CodePudding user response:

Individual is strongly recommended that all ADO operation and try... The catch... Print _com_error detailed error messages, or program will easily because of abnormal hang up,
You have any good database tutorial please reply, I will not regularly arrange,
 
//print calls ADO controls when the detailed error message
Void dump_com_error (_com_error & amp; E)
{
Cstrings ErrorStr;
_bstr_t bstrSource (e.S ource ());
_bstr_t bstrDescription (e.D escription ());
ErrorStr. The Format (\ n \ "tADO Error 08 lx \ n \ n \ tCode=% \ tCode fancy=% s \ n \ \ n \ tDescription tSource=% s=% s \ n \ n",
E.E rror (), e.E rrorMessage (), (LPCTSTR) bstrSource, LPCTSTR bstrDescription);
//print error information in the debug window, available in the Release version DBGView see error message
: : OutputDebugString (LPCTSTR ErrorStr);
# ifdef _DEBUG
AfxMessageBox (ErrorStr, MB_OK | MB_ICONERROR);
# endif
}

 
Try
{
//your ADO code

}
The catch (_com_error & amp; E)
{
Dump_com_error (e);
}

CodePudding user response:

It is school database tutorial is good,

CodePudding user response:

You single-step debugging, fault in where?
: : CoInitialize (NULL); I used to in the app
M_adoRecordSet - & gt; Open ((_bstr_t) TableName, _variant_t (m_adocon (IDispatch *), true), adOpenStatic, adLockOptimistic, adCmdTable);

CodePudding user response:

RST - & gt; Open (_variant_t (temp), _variant_t (con) (IDispatch *), adOpenDynamic, adLockOptimistic, 1); Can't stop here,,,

CodePudding user response:

How to solve the building Lord, solving!!!!!!
  • Related