Armenian Knowledge Base

Armenian Knowledge Base (https://forum.armkb.com/)
-   C/C++ (https://forum.armkb.com/c-c/)
-   -   C++ Builder 6 - Database Search (https://forum.armkb.com/c-c/22979-c-builder-6-database-search.html)

Rowin 02.05.2006 10:36

C++ Builder 6 - Database Search
 
Hi,
I have a table called event in my database.
I have 2 fields called Event_Id and Project_Id.
I want to search the table to find out if there's event_id=27 for a project_id.

Kind Regards,
Rowin

tiko_www 02.05.2006 13:16

Re: C++ Builder 6 - Database Search
 
CDatabase* pDatabase ;
...
...
CRecordset m_rs (pDatabase);

m_rs.Open(AFX_DB_USE_DEFAULT_TYPE, "select project_id from table_name where event_id = 27", NULL);

or

m_rs.Open();
m_rs.m_strFilter = "event_id = 27";
m_rs.Requery();


CDBVariant varValue;

while(!m_rs.IsEOF())
{
m_rs.GetFieldValue(2/*2 is column*/, varValue );
...
//cout << varValue.m_lVal;
...

m_rs.MoveNext();
}

Agregat 02.05.2006 21:10

Re: C++ Builder 6 - Database Search
 
Not sure how MFC fits inside BCB, but whatever

Rowin 03.05.2006 09:09

Re: C++ Builder 6 - Database Search
 
Thanks, I'll try it.

Kind Regards,
Rowin


All times are GMT. The time now is 00:42.

Powered by vBulletin® Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.