none
Error on the import statement

    Question

  • // chekdb1.cpp : main project file.



    #include

    "stdafx.h"


    #include

    <windows.h>


    #include

    <stdio.h>


    #include

    <conio.h>


    #include

    <iostream>


    using

    namespacestd;


    #import

    <"C:\Program Files (x86)\Common Files\System\ado\msado15.dll">rename("EOF", "EndOfFile")


    int

    main(intargc, char* argv[])

    {

    HRESULT hr = S_OK;

       

    try


        {

             CoInitialize(NULL);

             

    // Define string variables.


            _bstr_t strCnn(

    "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=ma;Initial Catalog=UNI;Data Source=FALCON;Workstation ID=FALCON");

           _RecordsetPtr pRstAuthors = NULL;

         

    // Call Create instance to instantiate the Record set


          hr = pRstAuthors.CreateInstance(

    __uuidof(Recordset));

         

    if(FAILED(hr))

          {

                cout<<

    "Failed creating record set instance\n";

               

    return0;

           }

         

    //Open the Record set for getting records from Author table


          pRstAuthors->Open(

    "SELECT * FROM student",strCnn, adOpenStatic,     adLockReadOnly,adCmdText);

         

    //Declare a variable of type _bstr_t


         _bstr_t valField1;

        

    intvalField2;

         pRstAuthors->MoveFirst();

       

    //Loop through the Record set


       

    if(!pRstAuthors->EndOfFile)

        {

          

    while(!pRstAuthors->EndOfFile)

           {

              valField1 = pRstAuthors->Fields->GetItem(

    "id")->Value;

              valField2 = pRstAuthors->Fields->GetItem(

    "name")->Value.intVal;

              cout<<

    "%d - %s\n"<<valField2<<(LPCSTR)valField1;

              pRstAuthors->MoveNext();

           }

        }

       }

      

    catch(_com_error & ce)

       {

          cout<<

    "Error:%s\n"<<ce.Description;

       }

      CoUninitialize();

     

    return0;

    }


    Tuesday, February 18, 2014 3:14 PM

All replies