MFC怎么让DIALOG1中点确定BUTTON后,在DIALOG2里的列表控件里显示刚才新添加的数据,我用的MySQL?
Testt;t.m_test.DeleteAllItems();CStringsql1;sql1="SELECT*FROM表名ORDERBYidDESCLIMIT1";D...
Test t;
t.m_test.DeleteAllItems();
CString sql1;
sql1 = "SELECT * FROM 表名ORDER BY id DESC LIMIT 1";
DBCon db;
MYSQL_RES * res = db.select(sql.GetBuffer(sql.GetLength()));
int item;
MYSQL_ROW row;
if (NULL != res)
{
while( (row = mysql_fetch_row(res)) != NULL )
{
item = jk.m_test.InsertItem(0, row[1]);
jk.m_test.SetItemText(item, 1, row[2]);
jk.m_test.SetItemText(item, 2, row[3]);
jk.m_test.SetItemText(item, 3, row[4]);
jk.m_test.SetItemText(item, 4, row[5]);
jk.m_test.SetItemText(item, 5, row[6]);
jk.m_test.SetItemText(item, 6, row[7]);
jk.m_test.SetItemText(item, 7, row[8]);
jk.m_test.SetItemText(item, 8, row[9]);
}
}
数据库链接没问题,在同一对话框里也会做,在其他对话框了就不太懂了,初学~所以还不能灵活应用,希望懂的人能指点一下我,谢谢!
没啥分 展开
t.m_test.DeleteAllItems();
CString sql1;
sql1 = "SELECT * FROM 表名ORDER BY id DESC LIMIT 1";
DBCon db;
MYSQL_RES * res = db.select(sql.GetBuffer(sql.GetLength()));
int item;
MYSQL_ROW row;
if (NULL != res)
{
while( (row = mysql_fetch_row(res)) != NULL )
{
item = jk.m_test.InsertItem(0, row[1]);
jk.m_test.SetItemText(item, 1, row[2]);
jk.m_test.SetItemText(item, 2, row[3]);
jk.m_test.SetItemText(item, 3, row[4]);
jk.m_test.SetItemText(item, 4, row[5]);
jk.m_test.SetItemText(item, 5, row[6]);
jk.m_test.SetItemText(item, 6, row[7]);
jk.m_test.SetItemText(item, 7, row[8]);
jk.m_test.SetItemText(item, 8, row[9]);
}
}
数据库链接没问题,在同一对话框里也会做,在其他对话框了就不太懂了,初学~所以还不能灵活应用,希望懂的人能指点一下我,谢谢!
没啥分 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询