|
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
how do you incorporate the GUI in C++?
|
|
|
|
|
You can use the standard Win32 controls, or if your are writing MFC code, then there are classes for every situation.
|
|
|
|
|
And if you are on Linux, then you probably want to look at gtk or QT. I'm not sure what Mac uses these days.
There's dozens of tool-kits available for Linux and Windows, many are cross-platform, too. Use google to find something you like, and suits your needs.
Keep Calm and Carry On
|
|
|
|
|
I think you meant to post that to the OP.
|
|
|
|
|
Apparenlty am using linux distro.
|
|
|
|
|
"Apparently"? So are you not sure?
Assuming it is linux then I suggest you google for "linux gui" as there are different options available. See also the message from k5054 above.
|
|
|
|
|
Use wxWidgets[^] GUI library, then your code will work on Windows, Linux and MacOS.
|
|
|
|
|
If you're a young guy, I'll take your answer too. I work in the land of embedded systems where nothing ever dies. Some of the systems I support use CE 4.2/5.0 and Embedded Visual C++ - a bastardized clone of VC++ 6.0 (I think). In EVC++ I can place my cursor on something I am interested in and press help - and I get help.
Years pass, and now I also support a variant using WEC7 and VS2008. No matter how many times I have installed VS2008, help is trashed. It just does not work. I have spend days over the past years trying to resolve this issue. I want to do something stupid simple like click on CString and press F1 to pull up the class description. Nope, never happens.
Any of you resolve this issue? Spoilers?
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
AFAIR, the latest VC++ edition that worked with the MSDN help good enough was VC++0.
In every new VS edition it worked either worse either didn't work at all.
|
|
|
|
|
0? lol, I agree. It's totally bizarre. I'll keep digging, maybe write my first article.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Hi C++ Gurus,
Below code is generating error code -2. Its working fine for sql queries like "select * from emp", but where as in Insert statement its returning error code. Please help.
Regards,
Suresh
#include "database.h"
int main(){
SQLRETURN ret = 0;
SQLHENV env;
SQLHDBC dbc;
SQLHSTMT stmt;
SQLSMALLINT msg_len = 0;
SQLCHAR sql_state[6], message[256];
SQLINTEGER native_error = 0;
try{
ret = SQLAllocEnv(&env);
ret = SQLAllocConnect(env, &dbc);
ret = SQLConnect(dbc, (SQLCHAR*)"KarTarDB", strlen("KarTarDB"), (SQLCHAR*)"sa",2,(SQLCHAR*)"KarTarPwd",9);
if(ret == SQL_INVALID_HANDLE || ret < 0) {
cout << "Connection open failure." << endl;
ret = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, sql_state, &native_error, message, sizeof(message), &msg_len);
cout << ret << endl;
} else{
char sql[100]="INSERT INTO emp(name, age, dob) VALUES ('john', 23, '010101')";
ret = SQLPrepare(stmt,(unsigned char*)sql, SQL_NTS);
ret = SQLExecute(stmt);
if(ret == SQL_ERROR || ret < 0) {
cout << "ResultSet Error: " << ret << endl;
}else{
cout << "Done" << endl;
}
}
}catch(...) {
cout << "Database error.." << endl;
}
return 0;
}
|
|
|
|
|
What is -2? According to MSDN SQLExecute Function - SQL Server | Microsoft Docs it can return the following:
Quote: SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NEED_DATA, SQL_STILL_EXECUTING, SQL_ERROR, SQL_NO_DATA, SQL_INVALID_HANDLE, or SQL_PARAM_DATA_AVAILABLE.
Besides
Quote: When SQLExecute returns either SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle.
|
|
|
|
|
Hi Victor, Thanks for your response.
As you can see in the code, I have already used SQLGetDiagRec.
ret = SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, sql_state, &native_error, message, sizeof(message), &msg_len)
But even that is returning -2 and not giving any other details, hence I commented it. Am I missing anything? How can I get more details from ret object apart from -2.
Regards,
Suresh
|
|
|
|
|
SureshBL wrote: But even that is returning -2 and not giving any other details, hence I commented it. Am I missing anything? How can I get more details from ret object apart from -2.
Well, -2 means SQL_INVALID_HANDLE.
So you need to go one step back and check why the handle is invalid!
|
|
|
|
|
Thanks
Do you see anything wrong with my Code?
As mentioned querying table is working fine with the connection, but Insert statement is making handle invalid.
SQLSTATE: l NativeError: 0 ErrMsg: 0x6cfce0
Apologies, I am learning c++ now. So I am not expert to understand lots of bits and pieces to debug the issue in every step.
Regards,
Suresh
modified 19-May-20 17:07pm.
|
|
|
|
|
Can't say I've ever used this, but shouldn't the SQLHSTMT variable 'stmt' be initialized with something?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
modified 19-May-20 17:31pm.
|
|
|
|
|
Ok got you. So I have to assign dbc to stmt?
ret = SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
|
|
|
|
|
Great Its working now. Thank you very much..
|
|
|
|
|
You're welcome.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Does anybody know where kernel32.lib could be found?
|
|
|
|
|
kernel32.lib is the library for kernel32.dll. It may be found in the Windows SDK, which is freely downloadable.
Most Windows compilers bundle a copy of it, and place it with their other libraries.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
|
I recently lost out on a great job because I couldn't pass the coding challenge. I was given a header file that I COULD NOT modify, and asked to fill it out with a stack with a linked list backbone. The problem was to reverse stack data (integers) such that nodes 1..4 contained 1, 2, 3, 4, and the output would be 4, 3, 2, 1. I easily wrote this, with one problem: none of the methods in the class signatures contained any output method other than top(), which returned the top node. Everything else was a void method. So I modified the size() method t]such that it output the values of each node.
I believe this is where I failed. The code contained a "node" class with a data member and a pointer to the next node. The stack class had a pop method, a push method, that size method, top, and that's about it. Both were templates. Other than adding a friend class or resorting to dirty pointer tricks, I could not figure out how to display the data members of the node class.
I really don't understand how this is a valid problem to pose.
Here is the header I was given:
#include <cstddef>
#pragma once
//a basic stack class.
//Implement all member functions in the file stack.cpp.
// then add a reasonable set of unit tests, with output, to main.cpp.
//Don't modify stack.h or CMakeLists.txt at all, unless you spot a mistake.
template <class t=""> struct _node
{
T _data;
_node<t>* _next;
_node(const T&, _node<t>*);
~_node();
};
template <class t=""> class stack
{
private:
_node<t>* _head;
size_t _size;
public:
stack();
~stack();
size_t size() const; //return the size of the stack
T& top() const; //return a reference to the top value. Throw an exception if the stack is empty.
void push(const T&); //push a new value onto the stack
void pop(); //remove the top value from the stack. Do nothing if the stack is empty.
void invert(); //reverse the order of the entire stack, so that 1,2,3,4,5 becomes 5,4,3,2,1 and so on.
//Your function should work in the most effecient way you can devise, ideally without allocating any memory on the heap.
};
|
|
|
|
|
Tim ONeil wrote: // then add a reasonable set of unit tests, with output, to main.cpp. You are supposed to add code in main to display the values, which you extract by repeated calls to the top and pop functions. The call to top gives you a reference to the value at the top of the stack. So you can display that with cout /printf . Follow that with a call to pop and the value you just looked at is now removed, ready for the next call to top . And so on.
|
|
|
|
|