Click here to Skip to main content
15,901,205 members
Home / Discussions / Database
   

Database

 
QuestionCan anyone help me with this one? Pin
Suresh Prasad3-Dec-04 10:40
Suresh Prasad3-Dec-04 10:40 
AnswerRe: Can anyone help me with this one? Pin
Mike Ellison3-Dec-04 11:13
Mike Ellison3-Dec-04 11:13 
GeneralRe: Can anyone help me with this one? Pin
Suresh Prasad3-Dec-04 11:29
Suresh Prasad3-Dec-04 11:29 
GeneralRe: Can anyone help me with this one? Pin
Mike Ellison3-Dec-04 11:48
Mike Ellison3-Dec-04 11:48 
GeneralRe: Can anyone help me with this one? Pin
Suresh Prasad3-Dec-04 11:57
Suresh Prasad3-Dec-04 11:57 
GeneralUploading Large numbers of records Pin
mjackson113-Dec-04 8:07
mjackson113-Dec-04 8:07 
GeneralRe: Uploading Large numbers of records Pin
Alex Korchemniy4-Dec-04 16:56
Alex Korchemniy4-Dec-04 16:56 
GeneralRe: Uploading Large numbers of records Pin
mjackson118-Dec-04 9:42
mjackson118-Dec-04 9:42 
FWIW, I got around this by creating a huge buffer to hold the data, pasting it to the clipboard, and using a COM object to get Access to paste the data. It is ugly as it appears you cannot import the Access library due to bugs, so I used old-fashioned COM. It was worth the effort as program run time went from over 5 minutes to under 40 seconds.

Mark Jackson

void mrgVaRProdList::uploadList(void)
{
#define APPEND_LINE_SIZE 120

mrgDataSrc * ds;
mrgRecSet rs;
list<mrgVaRPoint *>::iterator iter;
int i;
unsigned long _l, counter;
Date bd, d1, d2;
CString str, buf;
char * chr;
size_t bufLen;
HGLOBAL h;
HWND wh = GetConsoleHWND();

ds = _mParent->getDataObj();
rs.setDataSrc(ds);
bd.setDate(_mParent->getAsOfDate());
str = bd.getDateStr();
i = (int)_uploadList.size();
bufLen = i * APPEND_LINE_SIZE;
h = GlobalAlloc(GHND, bufLen);
try
{
if (!OpenClipboard(wh))
{
throw("OpenClipboard");
}
if (!EmptyClipboard())
{
throw("EmptyClipboard");
}
rs.ExecSQL("Delete * from VaRData");
iter = _uploadList.begin();
counter = 1;
_l = 0;
chr = (char *)GlobalLock(h);
while (iter != _uploadList.end())
{
buf.Format("%u\t%s\t", counter, str);
buf.AppendFormat("%u\t%u\t", (*iter)->idOne, (*iter)->idTwo);
d1.setDate((*iter)->bukOne);
d2.setDate((*iter)->bukTwo);
buf.AppendFormat("%s\t%s\t", d1.getDateStr(), d2.getDateStr());
buf.AppendFormat("%f\t%f\t%f\r\n", (*iter)->rho, (*iter)->sigmaOne, (*iter)->sigmaTwo);
for (i = 0; i < buf.GetLength(); i++)
{
chr[_l] = buf.GetAt(i);
_l++;
}
counter++;
iter++;
}
GlobalUnlock(h);
if (SetClipboardData(CF_TEXT, h) == NULL)
{
throw("SetClipboardData");
}
CloseClipboard();
}
catch(_com_error e)
{
PrintADOError(_T("ADO Error mrgVaRProdList.uploadList() : "), &e);
}
catch(const char *c)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
str.SetString((LPTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
cout << "Error in mrgVaRProdList.uploadList()-" << c << ":" << str.AllocSysString() << endl;
}
try
{
// our ID's
CLSID clsid;
IUnknown *pUnk;
IDispatch *pDisp;
IDispatch *pDispDoCmd;
DISPID dispid_DoCmd;
DISPID dispid_OpenTable;
DISPID dispid_RunCommand;
//parameter setup
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
OLECHAR FAR* szFunction;
// for getting/passing results
HRESULT hr;
VARIANT varResult;
// arguments for methods
VARIANT varArgs[1];
DISPPARAMS dpArgs;
BSTR bstrTemp;

CLSIDFromProgID(L"Access.Application", &clsid);

// Get an interface to the running instance, if any..
hr = GetActiveObject(clsid, NULL, (IUnknown**)&pUnk);
if (hr < 0)
{
// TODO - we need to start an instance
throw("Error GetActiveObject");
}

// Get IDispatch interface for Automation...
hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
if (hr < 0)
throw("Error QueryInterface - IID_IDispatch");
// Release the no-longer-needed IUnknown...
pUnk->Release();

szFunction = OLESTR("DoCmd");
hr = pDisp->GetIDsOfNames(IID_NULL, &szFunction, 1, LOCALE_USER_DEFAULT, &dispid_DoCmd);
if (hr < 0)
{
pDisp->Release();
throw("Error GetIDsOfNames for DoCmd");
}
hr = pDisp->Invoke(dispid_DoCmd, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
&dispparamsNoArgs, &varResult, NULL, NULL);
if (hr < 0)
{
pDisp->Release();
throw("Error Invoke for DoCmd");
}
pDispDoCmd = varResult.pdispVal;

szFunction = OLESTR("OpenTable");
hr = pDispDoCmd->GetIDsOfNames(IID_NULL, &szFunction, 1, LOCALE_USER_DEFAULT, &dispid_OpenTable);
if (hr < 0)
{
pDisp->Release();
pDispDoCmd->Release();
throw("Error GetIDsOfNames for OpenTable");
}

bstrTemp = ::SysAllocString(OLESTR("VaRData"));
varArgs[0].vt = VT_BSTR;
varArgs[0].bstrVal = bstrTemp;
dpArgs.cArgs = 1;
dpArgs.cNamedArgs = 0;
dpArgs.rgvarg = varArgs;

//Invoke the OpenTable Method
hr = pDispDoCmd->Invoke(dispid_OpenTable, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpArgs, NULL, NULL, NULL);
::SysFreeString(bstrTemp);
if (hr < 0)
{
pDisp->Release();
pDispDoCmd->Release();
throw("Error Invoking OpenTable");
}

szFunction = OLESTR("RunCommand");
hr = pDispDoCmd->GetIDsOfNames(IID_NULL, &szFunction, 1,
LOCALE_USER_DEFAULT, &dispid_RunCommand);
if (hr < 0)
{
pDisp->Release();
pDispDoCmd->Release();
throw("Error GetIDsOfNames RunCommand");
}

varArgs[0].vt = VT_I2;
varArgs[0].iVal = 0x26; // acCmdPasteAppend
dpArgs.cArgs = 1;
dpArgs.cNamedArgs = 0;
dpArgs.rgvarg = varArgs;
hr = pDispDoCmd->Invoke(dispid_RunCommand, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&dpArgs, NULL, NULL, NULL);

// release interface pointers
pDispDoCmd->Release();
pDisp->Release();
}
catch(_com_error e)
{
PrintADOError(_T("ADO Error mrgVaRProdList.uploadList() : "), &e);
}
catch(const char *c)
{
cout << "Error in mrgVaRProdList.uploadList()-" << c << endl;
}
return;
}

GeneralADO.NET columns are magic numbers.. Pin
giorgos_gr3-Dec-04 5:09
giorgos_gr3-Dec-04 5:09 
GeneralSQL Tree Hierarchy Problem Pin
Dirk Kok2-Dec-04 22:24
sussDirk Kok2-Dec-04 22:24 
GeneralRe: SQL Tree Hierarchy Problem Pin
Michael Potter3-Dec-04 4:34
Michael Potter3-Dec-04 4:34 
GeneralRe: SQL Tree Hierarchy Problem Pin
Chris Meech3-Dec-04 6:44
Chris Meech3-Dec-04 6:44 
GeneralStored Proc and SqlDataAdapter Pin
ccosser2-Dec-04 22:03
ccosser2-Dec-04 22:03 
GeneralAttaching a database to MSDE Pin
mattie202-Dec-04 20:31
mattie202-Dec-04 20:31 
GeneralNested Transaction with SQL Server Pin
Wouter van Eck2-Dec-04 5:21
Wouter van Eck2-Dec-04 5:21 
QuestionHow can i avaoid negative values in SQL? Pin
john kuruvila2-Dec-04 5:14
john kuruvila2-Dec-04 5:14 
AnswerRe: How can i avaoid negative values in SQL? Pin
Colin Angus Mackay2-Dec-04 6:42
Colin Angus Mackay2-Dec-04 6:42 
GeneralRe: How can i avaoid negative values in SQL? Pin
john kuruvila2-Dec-04 7:30
john kuruvila2-Dec-04 7:30 
Generalnot allowing negative values Pin
sujithapril2-Dec-04 5:10
sujithapril2-Dec-04 5:10 
GeneralRe: not allowing negative values Pin
Colin Angus Mackay2-Dec-04 6:41
Colin Angus Mackay2-Dec-04 6:41 
GeneralRe: not allowing negative values Pin
sujithapril2-Dec-04 7:23
sujithapril2-Dec-04 7:23 
GeneralRe: not allowing negative values Pin
Colin Angus Mackay2-Dec-04 7:26
Colin Angus Mackay2-Dec-04 7:26 
GeneralRe: not allowing negative values Pin
sujithapril2-Dec-04 7:50
sujithapril2-Dec-04 7:50 
GeneralRe: not allowing negative values Pin
Colin Angus Mackay2-Dec-04 7:59
Colin Angus Mackay2-Dec-04 7:59 
GeneralRecordset &quot;LIKE&quot; filter of a number column Pin
Menny Even Danan1-Dec-04 21:51
Menny Even Danan1-Dec-04 21:51 

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.