Solved

#import ADO\msado15.dll compiler error

Posted on 2004-10-10
6
1,158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

688 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