how to use adox to get primary key? Exception occurs!



Exception occurs when I try to get primary key using adox. The first
place is: table->Keys->Count, and the second place is print exception
when I try to catch the exception.
Anyone can help? Thanks very much.

try{
HRESULT hr = S_OK;

ADOX::_CatalogPtr catalog;

hr = catalog.CreateInstance(__uuidof (ADOX::Catalog));

catalog->PutActiveConnection(_variant_t((IDispatch *) m_connPtr));

ADOX::_TablePtr table = catalog->Tables->GetItem("user");

ADOX::_KeyPtr index;//key;

int c = table->Keys->Count; //Exception occurs here
}catch(_com_error e){
try{
cout << "Error at GetPrimaryKey, Description:" <<
(char*)e.Description() << ", Error message: " <<
(char*)e.ErrorMessage(); //Exception occurs again!!!
}catch(...){
}
}

.



Relevant Pages

  • RE: FormView, SqlDataSource and handling exceptions
    ... What i would do is check for the primary key in the database in the ... excpetion never gets generated and you return to the FormView in inserting ... violation and an exception is thrown. ... "Cannot insert duplicate record!"). ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HELP ME
    ... We need to execute update first and if SQL%ROWCOUNT < 1 then need to ... any User Define Exception to be handled and then use Raise Exception ... Above code template does not specify Commit statement. ... Name, Table primary key etc. ...
    (comp.databases.oracle.misc)
  • Re: Concurrency Exception and Enforce Contraints problem
    ... Dim currentRowInDb As JPAJobSchedulerDataSet.tblStaffRow = _ ... Everything works ok and when I force a concurrency exception the code ... The error is a contraints error, but I cannot work out which row or ... method because the primary key is then missing. ...
    (microsoft.public.dotnet.framework.adonet)
  • Copy data using SQL-DMO Transfer-method fails...
    ... course allready existing) tables on two different databases/servers. ... the Transfer-object (SQL-Server 7 compatible version) and the code is ... The code seems to transfer all rows ok, but it also raises an exception at ... Why is it trying to apply the primary key again? ...
    (microsoft.public.sqlserver.programming)
  • VB.NET DataRow.Find Method question
    ... I've rechecked the Database and all Primary Key columns are set correctly. ... question is why, when I run this section of code, do I get an exception? ...
    (microsoft.public.vsnet.general)