|
If you are talking about Date variable then you can get the desired format using -
CString Date = "12/05/2008";
CString YY,MM,DD;
int nLen;
nLen = Date.ReverseFind('/');
YY = Date.Right(nLen - 1);
Date = Date.Left(nLen);
nLen = Date.ReverseFind('/');
MM = Date.Right(nLen);
Date = Date.Left(nLen);
DD = Date;
CString sNewDateFormat;
sNewDateFormat.Format("%s/%s/%s",YY,MM,DD);
And if you are talking about the variable Datee, then the code written by you is fine.
|
|
|
|
|
manju#123 wrote: I am trying with the below code but i am getting the system time..
No surprise there since you are explicitly using sysTime members.
manju#123 wrote: can anyone help me
Yes. To get your yyyy/mm/dd format, use:
Datee.Format("%04d/%02d/%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay); Now if you are actually wanting to use the date in the Date variable, try:
CString Date = "12/05/2008";
COleDateTime dt;
dt.ParseDateTime(Date);
CString Datee = dt.Format("%Y/%m/%d");
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi all,
While adding a variable to a control in the dialog it is not getting reflected in the class.Please kindly help me out
Thank You
|
|
|
|
|
Try deleting the .ncb file and .clw file in your source folder and then reopening it. The intellisense goes wild sometimes.
BTW, how do you add the variable? using the class wizard and which compiler/version do you use?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks a million.It was indeed intellisense prob.By right clicking the control,variable["Add variable"]was added.Version 6 is being used
|
|
|
|
|
Hi,
I intend to make a sample application in VC++ to using MySQL databases.
Can anybody suggest me where and how to start?
I am new to databases any help would be great.
Thanks in Advance!!
Regards,
Tony
|
|
|
|
|
Visit this page http://www.codeproject.com/KB/database/[^] and set the language filter to C++ and skill to Beginner. There are plenty of articles that may give you a lead to begin with.
Note that there would be nothing specific to MySQL, but they will all speak about databases in general.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
|
Simple 7 Steps
1)First of all import msado15.dll into your workspace
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
2)Initialize COM libraries using
CoInitialize(NULL);
3) Create connection & record set pointers
_ConnectionPtr pConn("ADODB.Connection");
_RecordsetPtr pRst("ADODB.Recordset");
4) Open data base
#define STR_DATABASE L"DRIVER={sql server};SERVER=serverName;Database=datbaseName;" L"UID=sa; PWD=sa;"
HRESULT hr = S_OK;
hr = pConn->Open(STR_DATABASE, L"", L"", adOpenUnspecified);
if(FAILED(hr))
{
AfxMessageBox ("Error instantiating Connection object\n");
}
5)Execute Query and read values
try
{
CString strSQL("Select * From MyTable");
pRst->Open( _variant_t(strSQL),_variant_t((IDispatch *) pConn, true),adOpenDynamic, adLockReadOnly,adCmdText);
if(!pRst->EndOfFile){
CString strValue = (char*)(_bstr_t)pRst->Fields->Item["FieldName"]- >Value;
int nValue = (long)pRst->Fields->Item["FieldName"]->Value;
}
catch(_com_error &ce)
{
AfxMessageBox(ce.ErrorInfo);
OR
AfxMessageBox(ce.Description());
}
6)Close connection and record set pointers
if(pRst->State == adStateOpen)
pRst->Close();
if(pConn->State == adStateOpen)
pConn->Close();
7)UnInitialized COM library
::CoUninitialize();
|
|
|
|
|
Can i go like this as well
=========================================================================================
try
{
CDaoDatabase* pCDaoDb = NULL;
CDaoRecordset* pPointsSet = NULL;
pCDaoDb = new CDaoDatabase();
pCDaoDb->Open("C:\\temp\\sample2.mdb", FALSE, FALSE, "");
pPointsSet = new CDaoRecordset(pCDaoDb);
if (!pPointsSet->IsOpen())
{
pPointsSet->Open(dbOpenTable, "STUDENT", 0);
}
COleVariant oleVariant;
oleVariant = pPointsSet->GetFieldValue("STUDENTID");
long lTemp = oleVariant.lVal;
oleVariant = pPointsSet->GetFieldValue("Address");
CString strTemp = oleVariant.pcVal;
CString strTemp2 = strTemp.AllocSysString();
int nCount = pPointsSet->GetRecordCount();
//pPointsSet->
}
catch(CDaoException* e)
{
//int nError = e->ReportError();
CString error = e->m_pErrorInfo->m_strDescription;
MessageBox( NULL, error, "ERROR", MB_OK );
}
=========================================================================================
|
|
|
|
|
|
Hi!
I've used the following code to load an Object(A 3D Model).
m_Obj = new Object("Car");
m_Obj->LoadFile("demoMap/StaticMeshes/Pajero.IVE", false);
During Debugging, if I hover over m_Obj and view it as a XML file, it shows me:
"A name contained an invalid character. Error processing resource 'file:///C:/Documents and Settings/RATHAKRISHNAN/Local Set...
<bad ptr="">"
I've to use this variable to apply some material to the 3D Object. There it shows exception. How to overcome this Bad Ptr situation and resolve this exception?
|
|
|
|
|
debug the the LoadFile.
|
|
|
|
|
No. I got an exception while running the project. So I planned to inspect each variable by Debugging. While hover over this m_Obj variable, it shows Bad Ptr.
|
|
|
|
|
What line causes the exception?
m_Obj is an invalid pointer until the "new" succeeds.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am trying to provide the language support (chinese) to one of my sample application. I have translated the strings with the chinese equivalent strings. It is working fine. When I run the application, I am able to see my sample application GUI with the Chinese strings.
But one thing I would like to know is when I compile my chinese language dll, I am getting the warnings MySampleAppChinese.rc : Could not find the file.
Why are these warnings generated? What is the reason for this?
Thanks in advance.
Taruni
|
|
|
|
|
Hi,
How can initialize array of int with NULL after its declartion.
int a[5]={NULL};//Right?
int a[5];then later how can I do the same above
|
|
|
|
|
1. Declare and init
int array[5] = {0};
2. ReInit
(a) for (i=0; i<5; i++) array[i] = 0;
(b) memset(array, 0, 5*sizeof(int));
(c) ZeroMemory(array, 5*sizeof(int));
3. Dynamic declare and init
(a)int *array;
array = new int[5];
ZeroMemory(array, 5*sizeof(int));
(b)int *array;
array = (int*) calloc(5*sizeof(int));
modified on Monday, September 22, 2008 1:57 AM
|
|
|
|
|
hi...How to a webserver in VC++ ...
|
|
|
|
|
|
You have to know programming with socket
|
|
|
|
|
Hello guys,
I wanted to convert an HDC to a CBitmap object but I don't know how to.
How can I possibly manipulate HDC and probably create a CBitmap from it.
Hope you can help me with this one.
It will be a big help.
Thanks.
|
|
|
|
|
Can you more explain HDC is a handle to device context and HBITMPA is a handle to a bitmap,for make a bitmap you can use of CreateCompatibaleBitmap.
|
|
|
|
|
Here's some code that will retrieve the currently selected bitmap from a HDC.
It should be noted that GetCurrentObject will only return a valid BITMAP if the supplpied HDC is a memory DC.
If I tried to do dcBmp = (HBITMAP)GetCurrentObject(screenDC, OBJ_BITMAP), I'd get garbage results.
If the DC you're trying to copy is not a memory DC, the alternative you have is to determine the position on screen of the image, then do a BitBlt from the screenDC to a memoryDC that has already got a HBITMAP selected onto it.
Note that having a look into the BitBlt, SelectObject, & CreateCompatibleBitmap may be necessary.
HDC screenDC, memDC;
char buffer[200];
BITMAP bmInfo;
HBITMAP dcBmp;
screenDC = GetWindowDC(hwnd);
memDC = CreateCompatibleDC(screenDC);
HBITMAP myBmp = CreateCompatibleBitmap(memDC, 100, 100);
SelectObject(memDC, myBmp);
dcBmp = (HBITMAP)GetCurrentObject(memDC, OBJ_BITMAP);
if (dcBmp)
{
GetObject(dcBmp, sizeof(bmInfo), &bmInfo);
sprintf(buffer, "Bitmap is: %d x %d pixels.", bmInfo.bmWidth, bmInfo.bmHeight);
MessageBox(hwnd, buffer, "Title", MB_OK);
}
else
MessageBox(hwnd, "Error", "Title", MB_ICONEXCLAMATION);
|
|
|
|
|
i'm looking for subj sources. some plain realization but in plain C++, without classes.
i saw all realizations placed here.. they all MFC ((
Please, help with sources if You have! )
//wbr
|
|
|
|