Click here to Skip to main content
15,912,207 members
Home / Discussions / Database
   

Database

 
GeneralRe: Check table exist not Pin
Arjan Einbu18-Sep-03 22:36
Arjan Einbu18-Sep-03 22:36 
GeneralRe: Check table exist not Pin
Giovanni Bejarasco19-Sep-03 6:14
Giovanni Bejarasco19-Sep-03 6:14 
GeneralRe: Check table exist not Pin
Blake Coverett20-Sep-03 16:29
Blake Coverett20-Sep-03 16:29 
GeneralRe: Check table exist not Pin
Blake Coverett20-Sep-03 16:27
Blake Coverett20-Sep-03 16:27 
GeneralRe: Check table exist not Pin
Anonymous20-Sep-03 18:16
Anonymous20-Sep-03 18:16 
GeneralBinding a dataset to a checkbox Pin
Wjousts17-Sep-03 15:11
Wjousts17-Sep-03 15:11 
GeneralRe: Binding a dataset to a checkbox Pin
Wjousts18-Sep-03 5:12
Wjousts18-Sep-03 5:12 
GeneralADO API Pin
ranjjj17-Sep-03 4:08
ranjjj17-Sep-03 4:08 
_ConnectionPtr m_pConnection;
what does the above statement mean..?
i have to use the above mentioned in my program to get the data from my database..
can some one plzzz explain me on what it actually means...
and i've attached the code also with this query!
does the attached code really help me in making a connection with my database and getting the data from it....???

here's the code i had mentioned:

#include <windows.h>
#include <initguid.h> // Include only once in your application
#include "adoid.h" // ADO GUID's
#include "adoint.h" // ADO Classes, enums, etc.
#include <windows.h>
//#import <msado15.dll> rename("EOF", "adoEOF")


/*In this example, I am using mcb.krz database which is an access database.
The table i do have in example is 'Access' that has two fields,
i.e., Name and HTML, both are Text type fields. Microsoft.Jet.OLEDB.3.51 is OLE_DB provider
for MS Access. To use ADO, you must have OLE-DB provider for that database. */


// Create a Connection object and open it with mcb.krz, an access database


_ConnectionPtr m_pConnection;

BOOL m_bIsConnectionOpen;

// Create an instance of _Connection
HRESULT hr ;
hr = m_pConnection.CreateInstance(__uuidof( Connection) );

if (SUCCEEDED(hr))
{
//Open a connection where database is access database : "d:\mcb.krz"
hr = m_pConnection->Open( _bstr_t(L"Provider=Microsoft.Jet.OLEDB.3.51;
Data Source=d:\\mcb.krz;"), _bstr_t(L""), _bstr_t(L""), adModeUnknown ) ;

//If database opened successfully then set IsConnectionOpen to TRUE
if (SUCCEEDED(hr))
{
m_bIsConnectionOpen = TRUE;
}
}

_RecordsetPtr pRecordset;
// Here I take data from a table called KRUSE1 which has two fields a0, and a1 of TEXT type
_bstr_t bstrQuery("SELECT * FROM Kruse1");
_variant_t vRecsAffected(0L);

try
{
pRecordset = m_pConnection->Execute(bstrQuery, &vRecsAffected,adOptionUnspecified);

if ( !pRecordset->GetadoEOF())
{
int i = 0;
_variant_t vFirstName;
_variant_t vLastName;

while ( !pRecordset->GetadoEOF() )
{
vFirstName = pRecordset->GetCollect(L"a0") ;
vLastName = pRecordset->GetCollect(L"a1") ;
// now you got vFirstName and vLastName values and do whatever u want.
i++;
pRecordset->MoveNext();
}
}
pRecordset->Close();
}
catch( _com_error &e)
{
// get info from _com_error
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
TRACE("%s", e.ErrorMessage());
}
catch(...)
{
TRACE("*** UNHANDELED EXCEPTION ***");
}



ranjani
GeneralRe: ADO API Pin
Michael P Butler17-Sep-03 4:24
Michael P Butler17-Sep-03 4:24 
GeneralRe: ADO API Pin
ranjjj17-Sep-03 18:15
ranjjj17-Sep-03 18:15 
GeneralRe: ADO API Pin
Stefan Pedersen18-Sep-03 14:19
Stefan Pedersen18-Sep-03 14:19 
GeneralRe: ADO API Pin
ranjjj20-Sep-03 19:23
ranjjj20-Sep-03 19:23 
GeneralRe: ADO API Pin
Stefan Pedersen21-Sep-03 4:22
Stefan Pedersen21-Sep-03 4:22 
Questioncan someone help me with mysql??? Pin
Snyp16-Sep-03 15:40
Snyp16-Sep-03 15:40 
AnswerRe: can someone help me with mysql??? Pin
ZoogieZork16-Sep-03 16:30
ZoogieZork16-Sep-03 16:30 
Generalanon Pin
z-anon-z16-Sep-03 6:56
sussz-anon-z16-Sep-03 6:56 
QuestionHow to prevent connection being closed. Pin
esuvs200316-Sep-03 5:04
esuvs200316-Sep-03 5:04 
AnswerRe: How to prevent connection being closed. Pin
Mike Dimmick16-Sep-03 6:28
Mike Dimmick16-Sep-03 6:28 
GeneralOLE DB Provider for Sybase Pin
trangnguyen16-Sep-03 0:00
trangnguyen16-Sep-03 0:00 
QuestionField name? Pin
Hoornet9315-Sep-03 23:38
Hoornet9315-Sep-03 23:38 
AnswerRe: Field name? Pin
Stefan Pedersen18-Sep-03 14:21
Stefan Pedersen18-Sep-03 14:21 
GeneralRe: Field name? Pin
Hoornet9318-Sep-03 21:10
Hoornet9318-Sep-03 21:10 
AnswerRe: Field name? Pin
Tim Deveaux19-Sep-03 9:12
Tim Deveaux19-Sep-03 9:12 
GeneralADO namespace not accessible Pin
Pranoti15-Sep-03 23:25
Pranoti15-Sep-03 23:25 
GeneralOLE DB and ORACLE procedures Pin
Steve S15-Sep-03 22:07
Steve S15-Sep-03 22:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.