我照着例子用VC++做了一个商品交易管理系统,用ACESS2000的数据库,已经设置了共享,在控制面板的ODBC中添加数据源时 READONLY 的值也是零,在VC中数据查看方式是dynaset,可是当我用ADDNEW()函数向数据表里添加数据时,总是提示我该记录集是只读的。
       
        向各位高手求救!!!

解决方案 »

  1.   

    CString CMySet::GetDefaultConnect()
    {
    return _T("ODBC;DSN=商品交易管理数据源");
    }还有 m_nDefaultType =dynaset ;
    我觉的有用的就这些了啊,如果你要全部的,留下邮箱我发给你啊
      

  2.   

    // 商品交易管理系统View.cpp : implementation of the CMyView class
    //#include "stdafx.h"
    #include "商品交易管理系统.h"#include "商品交易管理系统Set.h"
    #include "商品交易管理系统Doc.h"
    #include "商品交易管理系统View.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CMyViewIMPLEMENT_DYNCREATE(CMyView, CRecordView)BEGIN_MESSAGE_MAP(CMyView, CRecordView)
    //{{AFX_MSG_MAP(CMyView)
    ON_BN_CLICKED(IDC_BUTTONADDNEW, OnButtonaddnew)
    ON_BN_CLICKED(IDC_BUTTONOK, OnButtonok)
    ON_EN_UPDATE(IDC_EDITXJ, OnUpdateEditxj)
    //}}AFX_MSG_MAP
    // Standard printing commands
    ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CMyView construction/destructionCMyView::CMyView()
    : CRecordView(CMyView::IDD)
    {
    //{{AFX_DATA_INIT(CMyView)
    m_pSet = NULL;
    //}}AFX_DATA_INIT
    // TODO: add construction code here}CMyView::~CMyView()
    {
    }void CMyView::DoDataExchange(CDataExchange* pDX)
    {
    CRecordView::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CMyView)
    DDX_FieldText(pDX, IDC_EDITJG, m_pSet->m_JG, m_pSet);
    DDX_FieldText(pDX, IDC_EDITJS, m_pSet->m_JS, m_pSet);
    DDX_FieldText(pDX, IDC_EDITJYRQ, m_pSet->m_JYRQ, m_pSet);
    DDX_FieldText(pDX, IDC_EDITSPBH, m_pSet->m_SPBH, m_pSet);
    DDX_FieldText(pDX, IDC_EDITSPMC, m_pSet->m_SPMC, m_pSet);
    DDX_FieldText(pDX, IDC_EDITXJ, m_pSet->m_XJ, m_pSet);
    //}}AFX_DATA_MAP
    }BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs return CRecordView::PreCreateWindow(cs);
    }void CMyView::OnInitialUpdate()
    {
    m_pSet = &GetDocument()->m_mySet;
    CRecordView::OnInitialUpdate();
    GetParentFrame()->RecalcLayout();
    ResizeParentToFit();}/////////////////////////////////////////////////////////////////////////////
    // CMyView printingBOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
    {
    // default preparation
    return DoPreparePrinting(pInfo);
    }void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
    {
    // TODO: add extra initialization before printing
    }void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
    {
    // TODO: add cleanup after printing
    }/////////////////////////////////////////////////////////////////////////////
    // CMyView diagnostics#ifdef _DEBUG
    void CMyView::AssertValid() const
    {
    CRecordView::AssertValid();
    }void CMyView::Dump(CDumpContext& dc) const
    {
    CRecordView::Dump(dc);
    }CMyDoc* CMyView::GetDocument() // non-debug version is inline
    {
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
    return (CMyDoc*)m_pDocument;
    }
    #endif //_DEBUG/////////////////////////////////////////////////////////////////////////////
    // CMyView database support
    CRecordset* CMyView::OnGetRecordset()
    {
    return m_pSet;
    }
    /////////////////////////////////////////////////////////////////////////////
    // CMyView message handlersvoid CMyView::OnButtonaddnew() 
    {
    // TODO: Add your control notification handler code here
    m_pSet->AddNew();
    UpdateData(FALSE);

    }void CMyView::OnButtonok() 
    {
    // TODO: Add your control notification handler code here
    UpdateData();
    m_pSet->Edit();
    m_pSet->m_XJ=m_pSet->m_JG*m_pSet->m_JS;
        UpdateData(TRUE);
    }void CMyView::OnUpdateEditxj() 
    {
    // TODO: If this is a RICHEDIT control, the control will not
    // send this notification unless you override the CRecordView::OnInitDialog()
    // function to send the EM_SETEVENTMASK message to the control
    // with the ENM_UPDATE flag ORed into the lParam mask.

    // TODO: Add your control notification handler code here

    }
      

  3.   

    请教楼主:
    Access数据库如何设置共享,谢谢了
      

  4.   

    Access 的“选项”中的“高级”有这个设置
      

  5.   

    晕,楼主用的是ODBC嘛,哪里是ADO?你先看看下面的!
    http://dev.csdn.net/develop/article/27/27337.shtm
    http://www.vckbase.com/document/viewdoc/?id=438你的基本思路有问题!
      

  6.   

    这些代码基本上都是按照书上的例子做的,只有
    //商品交易管理系统View.cpp 中的
    void CMyView::OnButtonaddnew() 
    {
    // TODO: Add your control notification handler code here
    m_pSet->AddNew();
    UpdateData(FALSE);

    }void CMyView::OnButtonok() 
    {
    // TODO: Add your control notification handler code here
    UpdateData();
    m_pSet->Edit();
    m_pSet->m_XJ=m_pSet->m_JG*m_pSet->m_JS;
        UpdateData(TRUE);
    }
    这两个函数是自己添加上去的,其他都是自动生成的
      

  7.   

    可是我的确是用VC的ADO控件去连接ODBC数据源啊
      

  8.   

    你用的啊ADO控件,但你的数据库连接和使用都是ODBC的!
      

  9.   

    可不可以告诉我你的QQ,我用QQ发给你好了
      

  10.   

    ado数据绑定控件返回的数据是只读的.