|
-
September 29th, 2009, 02:19 AM
#1
[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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|