|
Some hints...:
- You replied to the wrong person.
- The function you're referring to is
OnInitialUpdate() , nothing else. OnInitialUpdate() is called before the view is displayed, which means that your progress bar probably won't even show if your code is called from OnInitialUpdate() .- You have not formatted your code using <pre></pre> tags, which makes it hard to read.
- At best, the user will still experience a non-responsive application even if your advice is followed.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi all,
I am working on VC-2008, my problem is i have made a .h file and had defined some variables in it. And in other files i have used those global variables using extern. Now, when i compile the program its giving an error error LNK2001: unresolved external symbol "char Platform" (?Platform@@3DA), and if i include that .h file as header file it gives error variables already defined....
How can i do this??
Thanks in advance
|
|
|
|
|
(1) You should declare global variables as extern in a (shared) header (.h ) file.
(2) You should define global variables inside one source (.cpp ) file.
For instance:
(MyCommonHeader.h)
extern int goo;
(MyMainSource.cpp)
#include "MyCommonHeader.h"
int goo;
(MyOtherSource.cpp)
#include "MyCommonHeader.h"
BTW: You shouldn't use global variables.
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]
|
|
|
|
|
You can declare the variables as extern in the header file, and define them in any of cpp file.
|
|
|
|
|
hi,
how to show dialog box in maximized mode after running the dailog application? when dialog based app is ran then dialog will be in restroed down size, may i know how to dislpay dialog in maximized size.
thanks in advance.
|
|
|
|
|
Use
ShowWindow(SW_MAXIMIZE);
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
I have used this code to delete files from the current directory. But it not works.
Actually i cant use the full path. As because i dont know where my software will install. It may be D:\\or else also
SHFILEOPSTRUCT sfo;
sfo.pTo = NULL;
sfo.hwnd = NULL;
sfo.wFunc = FO_DELETE;
sfo.pFrom = "..\\Test\\*.txt\0";
sfo.fFlags = FOF_FILESONLY | FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI;
SHFileOperation(&sfo);
modified on Thursday, October 23, 2008 2:55 AM
|
|
|
|
|
You better use a complete path like "C:\\...\\*.txt
Greetings from Germany
|
|
|
|
|
Actually i cant use the full path. As because i dont know where my software will install. It may be D:\\or else also
|
|
|
|
|
Dont write files in the installation directory. Vista will knock you out!!!
Use a user path:
-> SHGetFolderPath
-> GetCurrentDirectory
-> write some path information in the registry (in the setup)
Greetings from Germany
|
|
|
|
|
Sk Mohiuddin wrote: sfo.pFrom = "..\\Test\\*.txt\0";
Documentation says:
pFrom
A pointer to one or more source file names. These names should be fully-qualified paths to prevent unexpected results.
I hope it helps.
BTW: You can use GetModuleFileName[^] to get the path of your executable.
Regards,
Sandip.
|
|
|
|
|
SEE MY CODE BELOW:
Ive got a dialog box where i enter Contact Details......
Ive To Insert IT Into Access Database........
//Take the values entered in edit box to CEdit *
m_First.GetWindowText(Firstname);
m_Last.GetWindowText(Lastname);
m_Add.GetWindowText(Address);
CString FullName = "INSERT INTO Contacts (FirstName, LastName, Address) VALUES ('" +Firstname+ "', '" +Lastname+"','" + Address+"'))";
executeSQL((SQLCHAR *) FullName);
ERROR :
CANNOT CONVERT CString to SQLCHAR*
|
|
|
|
|
anna mathew wrote: CANNOT CONVERT CString to SQLCHAR*
What the hell is an SQLCHAR* anyways?
anna mathew wrote: executeSQL((SQLCHAR *) FullName);
Why can't you just do it with the CString variable itself?
ExecuteSQL(FullName);
Why the wrong spelling (executeSQL instead of ExecuteSQL)? Is that a separate function you wrote?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: What the hell is an SQLCHAR* anyways?
Is is a ODBC API's data type:
typedef unsigned char SQLCHAR;
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]
|
|
|
|
|
Looks like MSDN doesn't know it but...
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Sure [^]?
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]
|
|
|
|
|
Touché!
I just did a search on MSDN, but the results were of no avail to reveal this secret datatype.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
thank you....
i tried it..but a new error comes up
error C2594: 'static_cast' : ambiguous conversions from 'void (__thiscall CInsert::* )(void)' to 'AFX_PMSG'
|
|
|
|
|
anna mathew wrote: i tried it..but a new error comes up
You tried what? Why don't you just show the code and be precise in asking questions? Do we need to ask you 10 questions just to get to know your exact problem?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: You tried what? Why don't you just show the code and be precise in asking questions? Do we need to ask you 10 questions just to get to know your exact problem?
Ya sir, but plz plz help, u r aware: your signature says it all
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]
|
|
|
|
|
I haven't understood yet if you're calling a CDatabase method or not, because I cannot find a ExecuteSQL function in ODBC API .
If you're using MFC to do database access then you don't need SQLCHAR data type.
Could you please post a more complete code snippet (don't forget to format it using 'code block' button)?
Could you you please explain better the scenario and your requirements?
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]
|
|
|
|
|
look what a SQLCHAR* is i guess SQLCHAR[] make one and copy the CString to it.
Greetings from Germany
|
|
|
|
|
Why do you need SQLCHAR ? Aren't you using CDatabase ?
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]
modified on Thursday, October 23, 2008 3:55 AM
|
|
|
|
|
now im using CDatabase....
and modified code to :
void CInsert::OnBnClickedOk()
{
OnOK();
SQLRETURN sr;
SQLHSTMT hstmt;
//SQLCHAR SQL[] ="INSERT INTO Contacts (FirstName, LastName, Address) VALUES('?','?','?')";
//Take the values entered in edit box to CEdit *
m_First.GetWindowText(Firstname);
m_Last.GetWindowText(Lastname);
m_Add.GetWindowText(Address);
CString Full ="INSERT INTO Contacts (FirstName, LastName, Address) VALUES ('" +Firstname+ "', '" +Lastname+"','" + Address+"'))"; SQLINTEGER FirstNameLength = SQL_NTS;
sr = ExecuteSQL(Full);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in ExecuteSQL");
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}
................
still now same error.........
error C2594: 'static_cast' : ambiguous conversions from 'void (__thiscall CInsert::* )(void)' to 'AFX_PMSG'
|
|
|
|
|
Ive Edited My Code To:
void CInsert::OnBnClickedOk()
{
OnOK();
SQLRETURN sr;
SQLHSTMT hstmt;
SQLCHAR SQL[] ="INSERT INTO Contacts (FirstName, LastName, Address) VALUES('?','?','?')";
//Take the values entered in edit box to CEdit *
m_First.GetWindowText(Firstname);
m_Last.GetWindowText(Lastname);
m_Add.GetWindowText(Address);
SQLINTEGER FirstNameLength = SQL_NTS;
SQLINTEGER AddressLength = SQL_NTS;
SQLINTEGER LastNameLength = SQL_NTS;
SQLINTEGER FullLength = SQL_NTS;
// Allocate a new statement handle
sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
// Prepare statement
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in SQLAllocHandle in OnViewTestpreparedinsert");
sr = SQLPrepare(hstmt, SQL, SQL_NTS);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in SQLPrepare in OnViewTestpreparedinsert");
// Bind Parameters
sr = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 10, 0,
&Firstname, sizeof(Firstname), &FirstNameLength);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in Binding 2 in OnViewTestpreparedinsert");
sr = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT,
SQL_C_CHAR, SQL_CHAR, 10, 0, &Lastname, sizeof(Lastname), &LastNameLength);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in Binding 3 in OnViewTestpreparedinsert");
sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT,SQL_C_CHAR, SQL_CHAR, 10, 0,
&Address, sizeof(Address), &AddressLength);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in Binding 3 in OnViewTestpreparedinsert");
// Execute statement with parameters
sr = SQLExecute(hstmt);
if(sr != SQL_SUCCESS && sr != SQL_SUCCESS_WITH_INFO)
displayODBCError(sr,"Error in SQLExecute in OnViewTestpreparedinsert");
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
}
...................................................................
Ive Also Tried ...........
void CInsert::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
OnOK();
SQLRETURN sr;
//Take the values entered in edit box to CEdit
m_First.GetWindowText(Firstname);
m_Last.GetWindowText(Lastname);
m_Add.GetWindowText(Address);
CString FullName = "INSERT INTO Contacts (FirstName, LastName, Address) VALUES ('" +Firstname+ "', '" +Lastname+"','" + Address+"'))";
executeSQL((SQLCHAR *) (LPCTSTR)FullName);
}
................................
Both I get the Same ERROR::::::
error C2594: 'static_cast' : ambiguous conversions from
'void (__thiscall CInsert::* )(void)' to 'AFX_PMSG'
........................Y Is It?
|
|
|
|
|