1. Need help with Execute method of Command object
I am newly into ADO. Have written a small test program to create a table in
an Access database. I am trying to use the Execute method of the Command
object. However I am getting a null pointer assignment somewhere in my
program.
Since the SQL query I am firing is a non-recordset returning one, I am
passing all NULLs to the Execute method. Is that all right?
Also, the MSDN documentation for the Command.Execute method (which is in
Visual Basic syntax, and to which I am not too familiar) says that this
method takes only 3 parameters. But I got a compilation error on using only
3 parameters. On looking into adoint.h, I saw that the function takes 4
parameters. Can someone show me the light on this?
I could get similar queries to work with the Recordset.Open method.
Thanks in advance.
Sabyasachi Basu
#define DBINITCONSTANTS
#define INITGUID
#include <windows.h>
#include <ole2.h>
#include <adoint.h>
#include <adoid.h>
#include <iostream.h>
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int
nShowCmd)
{
CoInitialize(NULL);
ADOConnection * pCon = NULL;
CoCreateInstance (CLSID_CADOConnection,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADOConnection,
(void **)&pCon);
HRESULT hr = pCon->Open(_T("data source=testDSN;user id=;password=;"),NULL,
NULL, 0);
if (SUCCEEDED(hr))
MessageBox(NULL, _T("Data source opened"), _T("Debug"), MB_OK);
ADOCommand *pComm = NULL;
CoCreateInstance(CLSID_CADOCommand,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADOCommand,
(void **)&pComm
);
pComm->put_CommandText(_T("CREATE TABLE myTable3 (id3 int not NULL)"));
VARIANT vConn;
vConn.vt = VT_UNKNOWN;
vConn.punkVal = (IUnknown *)pCon;
pComm->put_ActiveConnection(vConn);
hr = pComm->Execute(NULL, NULL, NULL, NULL);
if (TRUE == SUCCEEDED(hr))
MessageBox(NULL, _T("Command Execute succeeded!"), _T("Debug"), MB_OK);
else
MessageBox(NULL, _T("Command Execute failed!"), _T("Debug"), MB_OK);
pCon->Close();
pComm->Release();
pCon->Release();
CoUninitialize();
return 0;
2. Remote Views
3. Cannot Open any tools in SQL 2000
4. Newbie need help for execute method pls
5. US-GA - ATL - Oracle 7 DBA - Tuning,replication,
6. Help executing DTS Package needed
7. How can I get iSQL_w to show all the Money decimal places?
8. DTS Lookup doesn't have an Execute method
10. Return Status of DTS Package .Execute Method