Hi There All,
I wonder if someone could please help me with a problem that I am having trying to run an Access 2000 module via a small C++ DLL, using COM.
I am trying to use the Run method of the Access 2000 type library, to run the appropriate module, which has been developed under Access 2000 using VB.
The problem that I am having is to do with the fact that the Run method can accept up to 30 parameters, but I am only passing 20 parameters and so when I compile up, I get an error saying that the function does not take 20 parameters. I have modified the function prototype in msacc9.cpp and the hedare file for just 2 parameters, as a test and it compiles OK. However when I run it I noe get a bad variable type error from the access DB when I try to run the module. I know thatthe run method can take any number of parameters, so do I need to use funtion overloading to declare the Run method with only 20 parameters, or am I missing something.
I am passing the 2 arguements (first 1 a float and second 1 a string) using a tagvariant struct.
Code follows :-
char retval = ' ';
_Application openaccess;
tagVARIANT arg1,arg2;
int res;
arg1.dblVal = 12.34;
arg2.pcVal = "Test";
// initialise COM
res = CoInitializeEx(0, COINIT_MULTITHREADED);
if(res)
{
AfxMessageBox ("Coinitialise Error");
return ('1');
}
// Start Access and get Application object.
if(openaccess.CreateDispatch("Access.Application") == 0)
{
AfxMessageBox("Couldn't start Access and get Application object.");
return ('1');
}
openaccess.SetVisible(FALSE);
openaccess.OpenCurrentDatabase("c:\data.mdb",FALSE)
//Error displayed after this next line is traced into
openaccess.Run ("sp_update",&arg1,&arg2);
openaccess.CloseCurrentDatabase();
openaccess = NULL;
Thanks a lot for you help.
I wonder if someone could please help me with a problem that I am having trying to run an Access 2000 module via a small C++ DLL, using COM.
I am trying to use the Run method of the Access 2000 type library, to run the appropriate module, which has been developed under Access 2000 using VB.
The problem that I am having is to do with the fact that the Run method can accept up to 30 parameters, but I am only passing 20 parameters and so when I compile up, I get an error saying that the function does not take 20 parameters. I have modified the function prototype in msacc9.cpp and the hedare file for just 2 parameters, as a test and it compiles OK. However when I run it I noe get a bad variable type error from the access DB when I try to run the module. I know thatthe run method can take any number of parameters, so do I need to use funtion overloading to declare the Run method with only 20 parameters, or am I missing something.
I am passing the 2 arguements (first 1 a float and second 1 a string) using a tagvariant struct.
Code follows :-
char retval = ' ';
_Application openaccess;
tagVARIANT arg1,arg2;
int res;
arg1.dblVal = 12.34;
arg2.pcVal = "Test";
// initialise COM
res = CoInitializeEx(0, COINIT_MULTITHREADED);
if(res)
{
AfxMessageBox ("Coinitialise Error");
return ('1');
}
// Start Access and get Application object.
if(openaccess.CreateDispatch("Access.Application") == 0)
{
AfxMessageBox("Couldn't start Access and get Application object.");
return ('1');
}
openaccess.SetVisible(FALSE);
openaccess.OpenCurrentDatabase("c:\data.mdb",FALSE)
//Error displayed after this next line is traced into
openaccess.Run ("sp_update",&arg1,&arg2);
openaccess.CloseCurrentDatabase();
openaccess = NULL;
Thanks a lot for you help.