Dao To ADO

Hello guys,

I'm currently trying to rework an older project. It uses the Dao interface to connect to a MS-Access database. It now needs to connect to a SQL CE Database using the ADO driver.

However, I keep getting the IDispatch error, see below.

CJapRecordsets is a class with membervariables that inherits from _RecordsetPtr.

I'm not sure if it should inherit _RecordsetPtr or CADORecordset.

I did try to change it to CADORecordset(this seems to be working out better - there are functions that do not exist in _RecordsetPtr even though I need them). However I get an IDispatch Error #3105 here...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
			rs = new CJapRecordsets(Global::MyDatabase);

		if(!Global::MyDatabase->IsOpen())					
		{
					Global::MyDatabase->Open("Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=C:\JAP-MAIN.sdf;");	
		}
		
		

		if(!rs->IsOpen())
		{
			// This causes the IDispatch error	
			rs->Open(Global::MyDatabase->GetActiveConnection().GetInterfacePtr(),"SELECT * FROM Gesamt", 1);
		}


I can open the database successfully and check if the recordset is open or closed. However, upon trying to execute a select query, I keep getting an IDispatch error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

#include "stdafx.h"
#include "JAP.h"
#include 
#include "JapRecordsets.h"



#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CJapRecordsets

IMPLEMENT_DYNAMIC(CJapRecordsets, CJapRecordsets)

CJapRecordsets::CJapRecordsets(CADODatabase* pdb)
	: CADORecordset(pdb)
{

	m_NAME1 = _T("");
	m_VORNAME1 = _T("");
	m_NAME2 = _T("");
	m_VORNAME2 = _T("");
	m_ARTIKEL = _T("");
	m_TITEL = _T("");
	m_UNTERTITEL = _T("");
	m_AUFLAGE = _T("");
	m_ORT = _T("");
	m_JAHR = _T("");
	m_BJAHR = _T("");
	m_FORMAT = _T("");
	m_ILLUSTRA = _T("");
	m_EINBAND = _T("");
	m_BEIGABEN = _T("");
	m_NACHWEIS = _T("");
	m_ZUSTAND = _T("");
	m_W_HRUNG = _T("");
	m_ZUSCHLAG = 0.0f;
	m_SIGEL = _T("");
	m_KENNZ = _T("");
	m_SORT = 0.0;
	m_JAP = 0;
	m_MYLISTFLAG = FALSE;
	m_ID = 0;
	m_nFields = 25;

	m_nDefaultType = 0;
}


CString CJapRecordsets::GetDefaultDBName()
{
	return _T(".\\JAP-MAIN.sdf");
}

CString CJapRecordsets::GetDefaultSQL()
{
	return _T("SELECT * FROM [Gesamt]");
}

void CJapRecordsets::DoDataExchange(CDataExchange* pDX) 
{
		
// Currently empty, must be changed later, dno how though
// Member variables must be asigned
// m_NAME1 must be the cell value of the column "NAME1"
}

/////////////////////////////////////////////////////////////////////////////
// Diagnose CJapRecordsets

#ifdef _DEBUG
void CJapRecordsets::AssertValid() const
{
//	CADORecordset::AssertValid();
}

void CJapRecordsets::Dump(CDumpContext& dc) const
{
//	CADORecordset::Dump(dc);
}
#endif //_DEBUG 
Topic archived. No new replies allowed.