|
Is there an equivilent to the DateTime.Now() in asp.net, I'm writing a time stamp to sql server, and wanted to keep the same format.
dbUA->pzDateOpened = some sort of DateTime.Now();
|
|
|
|
|
GetCurrentTime() function should work for you. [^]
Every new day is another chance to change your life.
|
|
|
|
|
I didn't understand how to make the request, but I will look into again today.
|
|
|
|
|
Hi,
You can use GetLocalTime()..
SYSTEMTIME st;
GetLocalTyme(&st);
Thanks,
Satheesh
|
|
|
|
|
Yeah I saw that, but it looks like I have to build up my Date Time with a structure or something. I didn't understand how to make the request. Perhaps I read it wrong, will look into again today.
You included a sample, will give it a spin today. Thanks.
|
|
|
|
|
According to MSDN _ftime[^] is the equivalent.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks for the help Richard.
I was trying to inject the results into a datetime column in SQL via ODBC, but between the 2, it was hard to nail down the error. I didn't know if it was the format of the data, or ODBC not wanting to accept the LPSYSTEMTIME structure, or the size/precision of the data, which for some reason is 23,3.
Ended up with this for now, it works, I can modify it later if I find something better.
SYSTEMTIME systemTime;
GetSystemTime(&systemTime);
LPSYSTEMTIME lpSystemTime = &systemTime;
swprintf_s(szDateOpened,
L"%d-%d-%d %d:%d:%d",
systemTime.wMonth,
systemTime.wDay,
systemTime.wYear,
systemTime.wHour,
systemTime.wMinute,
systemTime.wSecond
);
szDateOpened[wcslen(szDateOpened)] = L'\0';
And then sent it to the ODBC Driver in another function. I just need to figure how how to create a MD5 Hash in UT8 for the Encoded Password, and then this part of the program is done.
L"INSERT INTO UserInfo(FirstName, LastName, UserName, PhraseHint, Phrase, PasswordClear, DateOpened, Email, FrontAdmin, SecurityLevel, Enabled, LastLogin) "
L"VALUES(?, ?, ?, ?, ?, ?, CAST(? as datetime), ?, ?, ?, ?, CAST(? AS datetime) )"
and parameterized the values, that one liner took all day long.
retcode = SQLBindParameter(hstmt, 12, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_VARCHAR, 23, 3, pzLastLogin, wcslen(pzLastLogin), NULL);
|
|
|
|
|
I'm afraid my SQL skills are non-existent, but I would suggest you do not store dates and/or times as text values in a database but as datetime (i.e. binary) values. The remarks section in the documentation[^] suggest how to convert it to a large integer. This seems like a lot of work just to save a simple value, but it is Microsoft.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I casted it as datetime, in the ? mark, so sql server does the conversion. CAST(? as datetime)
I'm starting to find out that SQL Server is not that popular in c++. must be a asp.net thing. Oh well. That was easy compared to hashing the password.
|
|
|
|
|
Hi,
SYSTEMTIME st;
GetLocalTime(&st);
CString strHour, strMinute, strSecond;
strHour.Format(_T("%d"), st.wHour);
strMinute.Format(_T("%d"), st.wMinute);
strSecond.Format(_T("%d"), st.wSecond);
You can use this to get the current time. I f you need to update the time automatically.Use a timer with one second elapse time, and use this code in OnTimer().
Thanks
|
|
|
|
|
I try this[^] CControlBar, and goes very well .. into CMainFrame ... I try to implement it into CChildFrame, but has failed ... it can be dock an CControlBar ( or extended ) into CChildFrame ?
Thanks !
|
|
|
|
|
See here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
This[^] is the first solution that I've tried, but seems not working in CControlBar case ...
|
|
|
|
|
Flaviu2 wrote: but seems not working
Which means?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I try in this way :
protected:
CControlBarExt m_wndControlBar;
CTestDialog m_cDialog;
and
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CMDIChildWnd::OnCreate(lpCreateStruct) == -1)return -1;
if(! m_wndControlBar.Create(this, &m_cDialog, CString("ControlBar Demo"), IDD_DIALOG1))
{
TRACE0("Failed to create dialogbar\n");
return -1; }
m_wndControlBar.SetBarStyle(m_wndControlBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndControlBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndControlBar);
return 0;
}
I get follow assetion failure :
ASSERT(pDockBar != NULL);
In the same way can be done CCOntrolBar in CMainFrame and goes well ...
|
|
|
|
|
Flaviu2 wrote: I get follow assetion failure :
Where? We cannot see your screen so have no way of knowing where these messages appear. Please make use of your debugger and trace what is happening in your code.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I succeded :
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CMDIChildWnd::OnCreate(lpCreateStruct) == -1)return -1;
if(! m_wndControlBar.Create(this, &m_cDialog, CString("ControlBar Demo"), IDD_DIALOG1))
{
TRACE0("Failed to create dialogbar\n");
return -1; }
m_wndControlBar.SetBarStyle(m_wndControlBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndControlBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndControlBar);
return 0;
}
and goes well ... thank you very much for your patience. Bye.
|
|
|
|
|
dear friends, I want to take input from user as :-
f(x)= y = ax^2 + bx + c
i.e. custom function input from user then parse it and then integrate it. But I have no idea how to do ir. Please help me or suggest any book.
|
|
|
|
|
Try a Google search for "calculator c++", this is a fairly common sample exercise.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
If you want to write it, then that's a hard thing. If you just want to use it, look at:
Fast Mathematical Expressions Parser[^] here on codeproject!
Good luck,
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
If you try to do everything at once, it's very hard. Breaking it into steps makes it simpler:
1. Turn the expression string into a list of tokens. A token can be a variable name, an operator, or a parenthesis.
2. Turn the token list into a tree of tokens, where each operator token has child tokens of its operands.
3. Integrate the lowest-level sub-expressions, than combine them according to the operators, e.g. the integral of A + B is the integral of A plus the integral of B.
====================================
For step 2, apply two rules to your token list until you have a single operator token left in the list, representing the whole expression. (If you end up with more than one token in the list, you probably started with an illegal expression):
1. If you have the pattern: "(", [token], ")", replace it with [token], i.e. delete parenthesis tokens around a single value.
2. In the most deeply-nested parentheses, replace [token] [operator] [token] in the list with [operator], and set [operator]'s left and right child-node pointers to the two token operands. Do this for the highest-precedence operators first.
|
|
|
|
|
Hi,
Well, the End result depends very much on the lanuage definitions you assume, and, what you want to do with the end result.
You need to define Language Rules, for instance, where do f,x,y,a,b,c come from.
In 'C' the compiler builds a Symbol Table, which is a cross referenced database of all variables encountered in a module.
What do you want to do with it. If you want to store it as a 'General Formula, your best bet is probably to convert it to RPN (Reverse Polish Notation) and write an RPN Evaluator for when the rubber hits the road,
In general, I would start with writing a Scanner,the Scanner breaks down the text into Tokens
the 'C' rules are like: A Variable starts with 'A..Z','a..z' or '_'
A Variable name can then be followed with the same, and the chars '0..9'
A Numerical starts with '0..9'
A White Space is a ' '(space), '\t' or a '\n'
So , in the above, the name of the first var is 'f', the next char is a '(' which is not a
legal char for a varname. So, the First token is a Lexical Token, with Identifier 'f'
The Next Token would be a Special Token, LPAREN,
Going on in general, (Your Language Definition does not allow for comments),
I would also write a Parser
The Parser calls the scanner , to pick off tokens One by One, ignoring intervening whitespace, or comments, and creates a parsing tree (But it all still depends what you want to do with the expression in the larger scheme of things.
A Book: Writing Compilers & Interpreters (An Applied Approach) by Ronald Mak, ISBN 0-471-50968-X
Bram
Bram van Kampen
|
|
|
|
|
I have tried to use a combination of get_offsetheight,get_offsetwidth,get_offsettop and getoffsetleft but the values returned are in reference to the immediate parent.
|
|
|
|
|
What do you mean by screen coordinates? Did you try "walking up" the inheritance tree, adding the offsets till you reach the top?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Hello.
That's exactly what the method you're invoking returns, the height/width referenced to its parent coordinate system.
If you want to get the offset referenced to the screen (1st level of DOM) you can get it by adding all offset values invoking recursively to 'get_offsetParent' method (n-1) times.
Hope it helps.
Regards
|
|
|
|
|