代码如下
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open(
"select distinct Time from Rules order by Time Desc",
_variant_t((IDispatch*)m_pMyConnect,true),
adOpenStatic,
adLockOptimistic,
adCmdText);
while(!m_pRecordset->adoEOF)
{
tmp=m_pRecordset->GetCollect(_variant_t((long)0));
COleDateTime dt = tmp.date;
int year = dt.GetYear();
int month=dt.GetMonth();
int day=dt.GetDay();
int hour=dt.GetHour();
int minute=dt.GetMinute();
int second=dt.GetSecond();
CString strTmp;
strTmp.Format("%d-%d-%d %d:%d:%d",year,month,day,hour,minute,second);
m_ComboCtrl.AddString(strTmp);//运行时失败
m_pRecordset->MoveNext();
}
///////////////////////////////////////////////////////////////////////////////
本意是初始ComboBox为空 程序初始化时从数据库中提取按降序提取时间段 插入到CComboBox::m_ComboCtrl里 不知为何错误???
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open(
"select distinct Time from Rules order by Time Desc",
_variant_t((IDispatch*)m_pMyConnect,true),
adOpenStatic,
adLockOptimistic,
adCmdText);
while(!m_pRecordset->adoEOF)
{
tmp=m_pRecordset->GetCollect(_variant_t((long)0));
COleDateTime dt = tmp.date;
int year = dt.GetYear();
int month=dt.GetMonth();
int day=dt.GetDay();
int hour=dt.GetHour();
int minute=dt.GetMinute();
int second=dt.GetSecond();
CString strTmp;
strTmp.Format("%d-%d-%d %d:%d:%d",year,month,day,hour,minute,second);
m_ComboCtrl.AddString(strTmp);//运行时失败
m_pRecordset->MoveNext();
}
///////////////////////////////////////////////////////////////////////////////
本意是初始ComboBox为空 程序初始化时从数据库中提取按降序提取时间段 插入到CComboBox::m_ComboCtrl里 不知为何错误???
解决方案 »
- 高分求助:ado访问db中文编码
- 请帮我解释解释 此代码 内中没见到
- 关于spin控件和CEdit控件的使用,edit控件无法写的问题
- 我的主对话框中有一个combo box,我想在对话框初始时把d:\1.txt中的记录逐条读入combo box,可是运行结果无错误,但对话框却不出现了。
- 关于对话框一问
- 我的程序为什么吃内存?高手请进!
- 1000分,急!Win98下,对于Kernel32.dll模块,VirtualProtect无法改变其不可写属性,如何改变?
- DNS lookup 问题?如何程序实现nslookup功能,来者有分,请UP。
- VC中,已知网上一幅图的URL,如何获得它的长和宽?
- dll注册
- Dialog 在属性里选中了Horz和Vert滚动条 请问怎样在程序中得到这两个滚动条的指针?
- richedit控件如何实现右键弹出菜单??
是这问题了,那初始化时就要显示该怎么做?
{
CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
box.AddString("A");
box.AddString("B");
box.AddString("C");
box.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
}如果你认为这样是不行的话.那你真的很菜.
解决了 两位的方法都ok的 thanks
ps:
to abuseyoudna1981
superpeel 的意思是放在Dialog的OnInitDialog里不行的 我也很菜 说不清楚 呵呵菜无所谓 我要的是热心 3x