Solved

#import ADO\msado15.dll compiler error

Posted on 2004-10-10
6
1,139 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

825 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