插入数据

 1 void CUserLoadDlg::OnBnClickedBtnadd()
 2 {
 3     // TODO: 在此添加控件通知处理程序代码
 4     UpdateData(TRUE);
 5     if(m_Name.IsEmpty() || m_PassWord.IsEmpty())
 6     {
 7         MessageBox("用户名或密码不能为空");
 8         return;
 9     }
10     m_LoginSet->AddNew();
11     m_LoginSet->m_username = m_Name;
12     m_LoginSet->m_pwd = m_PassWord;
13     m_LoginSet->Update();
14     m_LoginSet->Requery();
15 
16 }
17 
18 
19 //另:插入数据之前,表要打开,在初始化函数中可以选择打开表如下:
20 /*
21 BOOL CUserLoadDlg::OnInitDialog()
22 {
23     CDialog::OnInitDialog();
24 
25     // TODO:  在此添加额外的初始化
26     CString sql;
27     sql.Format("select * from tb_user ",m_Name,m_PassWord);
28     m_LoginSet = new Ctb_user(&((CMystudentsysApp*)AfxGetApp())->m_DB);
29     if(!m_LoginSet->Open(AFX_DB_USE_DEFAULT_TYPE,sql))
30     {
31         AfxMessageBox("tb_studentinfo 表打开失败!");
32     }
33 
34     return TRUE;  // return TRUE unless you set the focus to a control
35     // 异常: OCX 属性页应返回 FALSE
36 }
37 
38 */
原文地址:https://www.cnblogs.com/Ricezhang/p/3957775.html