[] 帮忙看下小弟我的代码能实现不?编译无异常 运行 程序崩溃
[求助] 帮忙看下我的代码能实现不?编译无错误 运行 程序崩溃
------解决方案--------------------
调试看看那条语句崩溃的?m_pSet哪儿来的?是有效值吗?
------解决方案--------------------
这里不对
m_ListTeacher.InsertItem(i,m_pSet->m_username);
m_ListTeacher.SetItemText(i,1,m_pSet->m_password);
m_ListTeacher.SetItemText(i,2,m_pSet->m_ID);
--》
m_ListTeacher.InsertItem(i,_T(""));
m_ListTeacher.SetItemText(i,0, m_pSet->m_username);
m_ListTeacher.SetItemText(i,1,m_pSet->m_password);
m_ListTeacher.SetItemText(i,2,m_pSet->m_ID);
------解决方案--------------------
程序崩溃的话,你Debug下call stack看下函数调用堆栈,看哪里出错了
------解决方案--------------------
一般是
m_list.InsertColumn( 0, "ID", LVCFMT_LEFT, 40 );//插入列
m_list.InsertColumn( 1, "NAME", LVCFMT_LEFT, 50 );
int nRow = m_list.InsertItem(0, "11");// 插入行
m_list.SetItemText(nRow, 1, "jacky");//设置其它列数据
- C/C++ code
CDatabase m_database; m_database.Open(NULL,FALSE,FALSE,_T("ODBC;Dsn=student;server=localhost;uid=;pwd=")); //打开数据源 DWORD dwExStyle = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP|LVS_EX_ONECLICKACTIVATE; m_ListTeacher.ModifyStyle(0,LVS_REPORT|LVS_SINGLESEL|LVS_SHOWSELALWAYS); m_ListTeacher.SetExtendedStyle(dwExStyle); m_ListTeacher.InsertColumn(0,"职工号",LVCFMT_CENTER,50,0); m_ListTeacher.InsertColumn(1,"姓名",LVCFMT_CENTER,50,0); m_ListTeacher.InsertColumn(2,"部门",LVCFMT_CENTER,50,0); CString strSQL; strSQL.Format("select * from user_pass"); //ListAll(strSQL); //打开教职工表,将所有记录显示在列表中 //return TRUE; // return TRUE unless you set the focus to a control if (m_pSet->IsBOF()) { // detects empty recordset return; } int i=0; do { m_pSet->MoveFirst(); while(!m_pSet->IsEOF()) { m_ListTeacher.InsertItem(i,m_pSet->m_username); m_ListTeacher.SetItemText(i,1,m_pSet->m_password); m_ListTeacher.SetItemText(i,2,m_pSet->m_ID); m_pSet->MoveNext(); //移到下一条记录 i++; } }while(i==100);
------解决方案--------------------
调试看看那条语句崩溃的?m_pSet哪儿来的?是有效值吗?
------解决方案--------------------
这里不对
m_ListTeacher.InsertItem(i,m_pSet->m_username);
m_ListTeacher.SetItemText(i,1,m_pSet->m_password);
m_ListTeacher.SetItemText(i,2,m_pSet->m_ID);
--》
m_ListTeacher.InsertItem(i,_T(""));
m_ListTeacher.SetItemText(i,0, m_pSet->m_username);
m_ListTeacher.SetItemText(i,1,m_pSet->m_password);
m_ListTeacher.SetItemText(i,2,m_pSet->m_ID);
------解决方案--------------------
程序崩溃的话,你Debug下call stack看下函数调用堆栈,看哪里出错了
------解决方案--------------------
一般是
m_list.InsertColumn( 0, "ID", LVCFMT_LEFT, 40 );//插入列
m_list.InsertColumn( 1, "NAME", LVCFMT_LEFT, 50 );
int nRow = m_list.InsertItem(0, "11");// 插入行
m_list.SetItemText(nRow, 1, "jacky");//设置其它列数据