Solved

#import ADO\msado15.dll compiler error

Posted on 2004-10-10
6
1,144 Views
Last Modified: 2008-02-01
In my Visual. c++ application (.net) I am trying to manage a database with the ADO control.
In the .h file I have:
#define INITGUID
#import "c:\Program Files\Common Files\System\ADO\msado15.dll"
                  rename_namespace("ADOCG") rename ("EOF","EndOfFile")
using namespace ADOCG;
#include "icrsint.h"

class CCustomRs :
      public CADORecordBinding
{
public:
};

class CCustomRs :
      public CADORecordBinding
{
public:
};
And when I compile the projecte (dialog based), I get these error:
....MyApp\Debug\msado15.tlh(2374) : error C2059: syntax error : '-'
....MyAppDebug\msado15.tlh(2374) : error C2238: unexpected token(s) preceding ';'
....MyApp\CustomRs.h(3) : error C2501: 'rename_namespace' : missing storage-class or type specifiers

Can help, please?
Marco53
0
Comment
Question by:marco53
  • 4
  • 2
6 Comments
 
LVL 34

Expert Comment

by:flavo
ID: 12274012
If you are using .Net, why not use the oledb class?
0
 

Author Comment

by:marco53
ID: 12274036
I am following a book "Visual C++ .NET " - Davis Chapman from Apogeo, and try to learning Visual C++.
What is the difference between ADO and oledb class?
Can I add and delete records from database?
Thanks
0
 
LVL 34

Expert Comment

by:flavo
ID: 12274046
Sure can.

If you are learning C++, have you considered C#??

In any case, i beleive all .Net languages can use the .net framework classes.. I must say i cant use C++ (bit of C# and compitent in dataAccess with VB .Net), ill see what i can do

Dave
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 34

Accepted Solution

by:
flavo earned 500 total points
ID: 12274054
Simple examples using the oledbCommand to access the db

//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataOleDbOleDbConnectionClassConnectionStringTopic.asp

 void CreateOleDbConnection()
 {
    String* myConnString = S"Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=Northwind;Integrated Security=SSPI;";
    OleDbConnection* myConnection = new OleDbConnection(myConnString);
    myConnection->Open();
    MessageBox::Show(String::Format( S"ServerVersion: {0}\nDataSource: {1}", myConnection->ServerVersion, myConnection->DataSource ));
    myConnection->Close();
 }

//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataOleDbOleDbCommandClassTopic.asp

public:
void ReadMyData(String* myConnString)
{
   String* mySelectQuery = S"SELECT OrderID, CustomerID FROM Orders";
   OleDbConnection* myConnection = new OleDbConnection(myConnString);
   OleDbCommand* myCommand = new OleDbCommand(mySelectQuery,myConnection);
   myConnection->Open();
   OleDbDataReader* myReader = myCommand->ExecuteReader();
   try
   {
     while (myReader->Read())
    {
       Console::WriteLine(S"{0}, {1}", __box(myReader->GetInt32(0)), myReader->GetString(1));
    }
   }
   __finally
   {
    // always call Close when done reading.
    myReader->Close();
    // always call Close when done reading.
    myConnection->Close();
 }
}


Dave
0
 

Author Comment

by:marco53
ID: 12274064
I am an Assembler programmer!! Since few months I am facing VC.NET.Its very hard to enter in this world. But I need for my job!!
Thanks for help
0
 
LVL 34

Expert Comment

by:flavo
ID: 12274071
Just google MSDN for C++ oledbCommand and you'll find your feet :)

Good Luck!

Dave
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question