I am trying to access a record of a table.I have written the follwoing code.But when I try to compile it gives some errors
fxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/ex.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
The following is the code I have written for it.
I would be glad if anyone can let me know if I need to change any settings.I m running it as a win32 Console application project
#include <iostream.h>
#include <stdlib.h>
#include <afx.h>
#define UC (char *)
#import "c:\program files\common files\system\ado\msado15.dll"rename("EOF","adoEOF" no_namespace
#define CREATEiNSTANCE(sp,riid) { HRESULT _hr = sp.CreateInstance( _uuidof(riid)); if (FAILED(_hr))_com_issue_error(_hr);}
#define RsITEM(rs,x) rs->Fields->Item[_variant_t(x)]->Value
struct InitOle{
InitOle(){::CoInitialize(NULL);}
~InitOle() {::CoUninitialize();}
}_init_InitOle;
void main()
{
int i,k;
_RecordsetPtr spRS;
_ConnectionPtr spCON;
try
{
CREATEiNSTANCE(spCON,Connection);
spCON->ConnectionString = L"driver={sql server};SERVER=(local);Database=pubs;"
L"driver;PWD=;";
spCON->ConnectionString = L"DRIVER = { Microsoft Access Driver (*.mdb)};"
L"DBQ=db1.MDB;DefaultDir=C:\\C++;";
CREATEiNSTANCE(spRS,Recordset);
spRS->PutRefActiveConnection(spCON);
spRS->Open("select * from Table1",vtMissing,adOpenKeyset,adLockBatchOptimistic,-1);
i=0;
while(spRS->adoEOF==false)
{
k = short (RsITEM(spRS,"ID");
spRS->MoveNext();
i ++;
}
spRS->Close();
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bs = _bstr_t("Error: " + _bstr_t (e.Error()) + _bstr_t(" Msg: " + _bstr_t(e.ErrorMessage()) + _bstr_t("Description:" + _bstr_t(e.Description());
MessageBox(0,bs,bstrSource,MB_OK);
}
}
#undef UC
Thanks in advance
Thiru
fxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/ex.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
The following is the code I have written for it.
I would be glad if anyone can let me know if I need to change any settings.I m running it as a win32 Console application project
#include <iostream.h>
#include <stdlib.h>
#include <afx.h>
#define UC (char *)
#import "c:\program files\common files\system\ado\msado15.dll"rename("EOF","adoEOF" no_namespace
#define CREATEiNSTANCE(sp,riid) { HRESULT _hr = sp.CreateInstance( _uuidof(riid)); if (FAILED(_hr))_com_issue_error(_hr);}
#define RsITEM(rs,x) rs->Fields->Item[_variant_t(x)]->Value
struct InitOle{
InitOle(){::CoInitialize(NULL);}
~InitOle() {::CoUninitialize();}
}_init_InitOle;
void main()
{
int i,k;
_RecordsetPtr spRS;
_ConnectionPtr spCON;
try
{
CREATEiNSTANCE(spCON,Connection);
spCON->ConnectionString = L"driver={sql server};SERVER=(local);Database=pubs;"
L"driver;PWD=;";
spCON->ConnectionString = L"DRIVER = { Microsoft Access Driver (*.mdb)};"
L"DBQ=db1.MDB;DefaultDir=C:\\C++;";
CREATEiNSTANCE(spRS,Recordset);
spRS->PutRefActiveConnection(spCON);
spRS->Open("select * from Table1",vtMissing,adOpenKeyset,adLockBatchOptimistic,-1);
i=0;
while(spRS->adoEOF==false)
{
k = short (RsITEM(spRS,"ID");
spRS->MoveNext();
i ++;
}
spRS->Close();
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bs = _bstr_t("Error: " + _bstr_t (e.Error()) + _bstr_t(" Msg: " + _bstr_t(e.ErrorMessage()) + _bstr_t("Description:" + _bstr_t(e.Description());
MessageBox(0,bs,bstrSource,MB_OK);
}
}
#undef UC
Thanks in advance
Thiru