|
Plz tell me how to do that?
If I want to get date before 7 days from current date?
How to do that?
|
|
|
|
|
Wow, you really need glasses because he even provided a code snippet showing exactly how to do it...
|
|
|
|
|
Bijo Pulikkottil wrote: If I have today date.
Based on what? Is it a CTime object? Is it a time_t variable? If you have the number of seconds since some epoch, can't you just subtract 86400 * 7 seconds?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi all,
i m using to Excel automation to read and write excel files.
i write excel file like this.
CoInitialize(NULL);
{
Excel::_ApplicationPtr XL;
HRESULT hr;
try
{
XL.CreateInstance(L"Excel.Application");
_variant_t var((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
XL->Workbooks->Add(Excel::xlWorksheet);
Excel::_WorksheetPtr pSheet = XL->ActiveSheet;
Excel::RangePtr pRange = pSheet->Cells;
Excel::RangePtr pBeginRange = pRange->Item[1][1];
Excel::RangePtr pEndRange = pRange->Item[1][1];
Excel::RangePtr pTotalRange = pSheet->Range[(Excel::Range*)pBeginRange][(Excel::Range*)pEndRange];
wchar_t wsz1[] = L"C";
wchar_t wsz2[] = L"D";
BSTR bstr1;
bstr1 = SysAllocString(wsz1);
BSTR bstr2;
bstr2 = SysAllocString(wsz2);
SAFEARRAYBOUND rgsabound[2] = { 0 };
rgsabound[0].cElements = 1;
rgsabound[0].lLbound = 0;
rgsabound[1].cElements = 1;
rgsabound[1].lLbound = 0;
VARIANT arr;
arr.vt = VT_ARRAY | VT_BSTR;
arr.parray = SafeArrayCreate(VT_BSTR,2,rgsabound);
long index[2];
index[0] = 0;
index[1] = 0;
hr = SafeArrayPutElement(arr.parray,index,bstr1);
pTotalRange->PutValue2(&arr);
VariantClear(&arr);
SysFreeString(bstr1);
SysFreeString(bstr2);
XL->Visible = true;
}
catch(_com_error &error)
{
cout << "COM error " << endl;
}
}
CoUninitialize();
when i write excel file i received this error
0x800706F7
"the stub received bad data"
please tell me how can i solve it.
thanks in advance.
|
|
|
|
|
if you have #imported the correct dlls and olbs for the installed version of Excel, everything seems fine.
|
|
|
|
|
This happens when i run application on Office 2010 Beta version.while i run application on office 2007 its working fine.
|
|
|
|
|
Hi sir,
I want to create a DSN Name and set a path for that.
I am using "SQLConfigDataSource" function for this.
It is not giving any error and running properly.But it is not writing to DNS.
Here ia wat i am doing
SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
Am i doing right???or any other stuff need to be done.
Thanks
Raj
|
|
|
|
|
Did you check the return value?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
I tried with this
bool aDSNCreated = false;
aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
printf("%d",aDSNCreated );
aDSNCreated value is zero.
what i am doing wrong??
Thanks
Raj
|
|
|
|
|
From MSDN[^]:
When SQLConfigDataSource returns FALSE, an associated *pfErrorCode value can be obtained by calling SQLInstallerError. The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi sir.
CPallini wrote: an associated *pfErrorCode value can be obtained by calling SQLInstallerError
I am not getting how to get the errorcode.I am trying as below
bool aDSNCreated = false;
RETCODE retcode= SQL_SUCCESS;
aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
printf("%d",aDSNCreated );
if(aDSNCreated == false)
{
retcode = SQLInstallerError(2, NULL,NULL,100,NULL);
}
I am not getting wat paramaters to send and return the error code..
please help me out.
Sorry i know its a very silly question.
Thanks
Raj
|
|
|
|
|
I would do:
BOOL isDSNCreated;
isDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
if (isDSNCreated == FALSE)
{
CHAR szError[SQL_MAX_MESSAGE_LENGTH];
DWORD dwError;
WORD cbError;
RETCODE retcode;
retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);
Hi sir,
I am getting this error:
Error 47 error C2664: 'SQLInstallerErrorW' : cannot convert parameter 3 from 'CHAR [512]' to 'LPWSTR'
Thanks
Raj
|
|
|
|
|
The use:
<big>TCHAR</big> szError[SQL_MAX_MESSAGE_LENGTH];
DWORD dwError;
WORD cbError;
RETCODE retcode;
retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);
<small>If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.<br>
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
<br></small><small><a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=1778670">[My articles]</a></small>
|
|
|
|
|
Hi sir,
Thank you.Its building without error.
I am getting the retcode as zero(i.e SQL_SUCCESS).
But i am not finding the DSN Created when i am checking through Control Panel->ODBC
Thanks
Raj
|
|
|
|
|
How can I store an position of point ( point of end/begin of an line ) which is within an rect ?
void CSelectTool::OnLButtonDown(CNetMapView* pView, UINT nFlags, const CPoint& point)
{
CRect rect = m_Tracker.m_rect;
...
CPoint ptLine;
if(rect.PtInRect(rectLine.TopLeft()))ptLine = rectLine.TopLeft();
if(rect.PtInRect(rectLine.BottomRight()))ptLine = rectLine.BottomRight();
...
}
now I need ptLine value in follow event :
void CSelectTool::OnMouseMove(CNetMapView* pView, UINT nFlags, const CPoint& point)
{
CRect rect = m_Tracker.m_rect;
}
|
|
|
|
|
If I got you then you have to move the line of the same amount of the rectangle. i.e.
- Store the original position of the rectangle.
- On mouse move, subtract to current rectangle position the stored one, to obtain the offset.
- add the offset to the line.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can you tell me how to insert / acces an struct elements from another class then declare it ?
...
...
typedef struct tagLine{
CDrawObj* pObj;
UINT nHandle;
CPoint point;
}Line;
...
...
CList<<Line,Line>> m_line;
...
void CSelectTool::OnLButtonDown(CMyView* pView, UINT nFlags, const CPoint& point)
{
pView->m_line.AddTail(pView->Line(pObj,1,point));
}
void CSelectTool::OnMouseMove(CMyView* pView, UINT nFlags, const CPoint& point)
{
}
Can you help me please ? Thank you !!!
modified on Wednesday, September 1, 2010 2:51 AM
|
|
|
|
|
Try something like following :
...
typedef struct tagLine {
int m_i1, m_i2;
Line(int i1, i2) : m_i1(i1), m_i2(i2) {};
} Line;
...
void CMyView::AddNewLine(int i1, int i2)
{
m_Line.AddTail(new Line(i1, i2));
}
virtual void BeHappy() = 0;
|
|
|
|
|
Ok , and when I want to acces an element of m_Line ?
|
|
|
|
|
MSDN has a code sample [^] about accessing elements of a CList .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
mesajflaviu wrote: pView->m_line.AddTail(pView->Line(pObj,1,point)); // this is error
If your structure is defined globally (not inside your class), then you can simply do something like this (given that the structure has the appropriate constructor and your m_line variable is public):
pView->m_line.AddTail(Line(pObj,1,point));
However, it is always better to make your variables private and provide a AddLine to your CMyView instead.
mesajflaviu wrote: // I don't know how to access element of pView->m_line;
The same way you wrote it. But once again, providing a getter is much more clean.
If you want to access a specific line in your list, then you have to use the methods from the list to retrieve the line you are looking for.
|
|
|
|
|
Here is my trial :
typedef struct tagLine{
CDrawObj* pObj;
UINT nHandle;
CPoint point;
}Line;
...
...
CList<Line,Line> m_line;
void CMyView::AddLineStruct(CDrawObj* pObj, UINT nHandle, CPoint point)
{
Line LineStruct;
LineStruct.pObj = pObj;
LineStruct.nHandle = nHandle;
LineStruct.point = point;
m_line.AddTail(LineStruct);
}
void CSelectTool::OnLButtonDown(CNetMapView* pView, UINT nFlags, const CPoint& point)
{
...
pView->AddLineStruct(pObjLine,nHandle,point);
...
}
void CSelectTool::OnMouseMove(CNetMapView* pView, UINT nFlags, const CPoint& point)
{
POSITION pos = pView->m_line.GetHeadPosition();
while(pos != NULL)
{
pView->Line data = pView->m_line.GetNext(pos);
}
}
still , I don't know how to acces elemts of the structure ....
|
|
|
|
|
Perhaps will go if I declare Line strucure as global , but I didn;t want to do that ... is not elegant
|
|
|
|
|
Why not ? If your structure has to be manipulated externally from your CMyView class, then it makes sense to make it a class which is not defined in your CMyView class (the class, not instances of the class of course).
And I would probably make it a class instead of a structure because you could add some useful methods to it (like check if the line is close enough to a given point, calculate the lenght of the line, ...). Of course, you can still do that with a structure but for most people using a structure in C++ means that it is an object that only contains data (and no method). This is of course not a strict rule.
|
|
|
|