VC6 ADO #Include HELP Please!!! 
Author Message
 VC6 ADO #Include HELP Please!!!

I'm trying to connect to a SQL server using ADO from VC6 I've created the
binding class as follows

class CCustomRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CCustomRs)
  ADO_FIXED_LENGTH_ENTRY(1, adInteger, m_l1, m_l1s, TRUE)
  ADO_FIXED_LENGTH_ENTRY(2, adInteger, m_l2, m_l2s, TRUE)
END_ADO_BINDING()

public:

 CCustomRs::CCustomRs() {m_l1 = m_l1s = m_l2 = m_l2s = 0;}

 long m_l1;
 ULONG m_l1s;

 long m_l2;
 ULONG m_l2s;

Quote:
};

I then try to connect and bind to the server as follows

 HRESULT hr;
 IADORecordBinding* pRb = NULL;

 ::CoInitialize(NULL);

 _RecordsetPtr pRs;
 CCustomRs rs;

 try
 {
  pRs.CreateInstance(__uuidof(Recordset));

  pRs->CursorLocation = adUseClient;

  pRs->Open( "SELECT * FROM TestData",
     "Provider=MSDASQL;DRIVER={SQL Server};SERVER=<Server
Name>;DATABASE=TESTDATA;UID=sa;PWD=",
     adOpenDynamic,
     adLockOptimistic,
     adCmdUnknown);

  if (FAILED(hr = pRs->QueryInterface(__uuidof(IADORecordBinding),
(LPVOID*)&pRb)))
   _com_issue_error(hr);

All well and good so far! I then try to bind....

  if (FAILED(hr = pRb->BindToRecordset(&rs)))
  {
   _com_issue_error(hr);
  }

This works if there is data in the table but fails spectacularly if the
table is empty!
I want it to bind either way!

Can anyone give me some advice on what i'm doing wrong?

The error code given is really useful
 Code = 800a0bcd
 Code meaning = Unknown error 0x800A0BCD Source = (null)
 Description = (null)

Any advice will be gratefully received!

Andy Blewitt



Fri, 16 Mar 2001 03:00:00 GMT  
 VC6 ADO #Include HELP Please!!!
Hi Andy,

Microsoft knows about this problem.  You must have at least
one record in the table.   I do not have a specific date as to when
this will be fixed.

Matt

Quote:

>I'm trying to connect to a SQL server using ADO from VC6 I've created the
>binding class as follows

>class CCustomRs : public CADORecordBinding
>{
>BEGIN_ADO_BINDING(CCustomRs)
>  ADO_FIXED_LENGTH_ENTRY(1, adInteger, m_l1, m_l1s, TRUE)
>  ADO_FIXED_LENGTH_ENTRY(2, adInteger, m_l2, m_l2s, TRUE)
>END_ADO_BINDING()

>public:

> CCustomRs::CCustomRs() {m_l1 = m_l1s = m_l2 = m_l2s = 0;}

> long m_l1;
> ULONG m_l1s;

> long m_l2;
> ULONG m_l2s;
>};

>I then try to connect and bind to the server as follows

> HRESULT hr;
> IADORecordBinding* pRb = NULL;

> ::CoInitialize(NULL);

> _RecordsetPtr pRs;
> CCustomRs rs;

> try
> {
>  pRs.CreateInstance(__uuidof(Recordset));

>  pRs->CursorLocation = adUseClient;

>  pRs->Open( "SELECT * FROM TestData",
>     "Provider=MSDASQL;DRIVER={SQL Server};SERVER=<Server
>Name>;DATABASE=TESTDATA;UID=sa;PWD=",
>     adOpenDynamic,
>     adLockOptimistic,
>     adCmdUnknown);

>  if (FAILED(hr = pRs->QueryInterface(__uuidof(IADORecordBinding),
>(LPVOID*)&pRb)))
>   _com_issue_error(hr);

>All well and good so far! I then try to bind....

>  if (FAILED(hr = pRb->BindToRecordset(&rs)))
>  {
>   _com_issue_error(hr);
>  }

>This works if there is data in the table but fails spectacularly if the
>table is empty!
>I want it to bind either way!

>Can anyone give me some advice on what i'm doing wrong?

>The error code given is really useful
> Code = 800a0bcd
> Code meaning = Unknown error 0x800A0BCD Source = (null)
> Description = (null)

>Any advice will be gratefully received!

>Andy Blewitt




Wed, 21 Mar 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!

2. VC6: Help with F1 Help, please

3. Please help!!!!Please help!!!!Please help!!!!

4. PLEASE HELP! Databas examples in VC6

5. PLEASE HELP - ODBC Excel MFC/VC6 Problem

6. VC6 Sample Projects won't compile in VC.NET..help please

7. VC6 Help Please - Opinions Wanted

8. Please Help! (Creating ActiveX Controls With VC6)

9. VC6 and please help

10. STL and VC6.0 (PLEASE HELP)

11. A VC6 problem, can someone PLEASE help..

12. Please help, Startup Problem after VC6 installed

 

 
Powered by phpBB® Forum Software