我建了一个对话框
然后加了ADO控件和DataGrid控件
ADO的属性中是 SELECT  *   FROM   dbo.Table_for_user
刚开始DataGrid中显示正常
但是当我好像改了DataGrid的一个属性后,DataGrid的显示就为空了
怎么回事
还有,怎么利用ADO控件向数据库插入记录
比如  
m_ado.SetRecordSource(_T("INSERT INTO dbo.Table_for_users(Account,PassWord) VALUES                     (m_strAccountName,m_strPsw)"));m_strAccountName 和  m_strPsw是CString,我是想插入它们存储的字符,应该怎么办
谢谢

解决方案 »

  1.   

    CString strSql;strSql.Format("INSERT INTO Table_for_users (Account,PassWord) VALUES ('%s','%s')",m_strAccountName,m_strPsw);
    m_ado.SetRecordSource(_T(strSql));
      

  2.   

    http://blog.csdn.net/BlueMap/archive/2010/07/06/5716313.aspx
      

  3.   

    datagrid操作(增删查改)可以参考俺的blog:
    http://blog.csdn.net/zxhx/archive/2011/04/12/6317592.aspx
    源代码可下载
      

  4.   

    SetRecordSource()
    函数不能使用insert,具体的看俺的代码实现吧
    俺用的模态对话框插入数据,默认前两列非空,你可以根据你的需要修改