CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Location
    Croatia - Zagreb
    Posts
    459

    [RESOLVED] SQLServer (ADO): Connection::Execute returns BD_E_NOTABLE

    Hi.

    I'm pretty new to DB programming and got a problem with simple db query.
    I'm using SQLServer Express2008 with ADO to connect and work with database.

    I created DB server and my own DB, in my DB I created 2 tables: "Users" and "Main".
    In Object Explorer in MSSQLServer Management studio, I see that the names of the table in my db are "dbo.Users" and "dbo.Main"

    code for connection and the query looks like this:
    (C++, VisualStudio2003)
    Code:
     _ConnectionPtr  pConnection;
     _RecordsetPtr   pRecordset;
     HRESULT hr;
    
      if(FAILED(hr = CoInitialize(NULL)))
      {
        printf("FAILED\n");
        return;
      }
    
      if(FAILED(hr = pConnection.CreateInstance(__uuidof(Connection))))
      {
        printf("FAILED\n");
        return;
      }
    
      if(FAILED(hr = pRecordset.CreateInstance(__uuidof(Recordset))))
      {
        printf("FAILED\n");
        return;
      }
    
     pConnection->Open(myConnStr,"","",-1);   
     try{
          pRecordset = pConnection->Execute("SELECT * FROM dbo.Users",NULL,1);
         }	catch(_com_error &e)
    	{
    	 return ;
    	}
    Even though my tables exists and I'm connected to db, _com_error still catches DB_E_NOTABLE exception.
    I tried "SELECT * FROM Users" with the same result.
    Maybe it can't find the table because the table is emtpy? But shouldn't this return 0 recorset or something?
    You just divided by zero, didn't you?

  2. #2
    Join Date
    Feb 2006
    Location
    Croatia - Zagreb
    Posts
    459

    Re: SQLServer (ADO): Connection::Execute returns BD_E_NOTABLE

    Solved. The problem was in the connection string where "Initial Catalog" was not specified.
    You just divided by zero, didn't you?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured