?
Solved

#import ADO\msado15.dll compiler error

Posted on 2004-10-10
6
Medium Priority
?
1,174 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 34

Accepted Solution

by:
flavo earned 1000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

743 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