|
hi all
i use the below to create a modeless dialog which works ok
CCPServerWait* m_pWaitDlg;
m_pWaitDlg = new CCPServerWait;
m_pWaitDlg->Create(IDD_DCPSERVER_WAIT);
m_pWaitDlg->m_wait_mes = "Connecting to CMIS Please
m_pWaitDlg->UpdateData(FALSE);
m_pWaitDlg->ShowWindow(SW_SHOW);
m_pWaitDlg->UpdateWindow();
m_pWaitDlg->DestroyWindow();
but before i use this code; i need to call the function
ok = SQLCreateDataSource(m_hWnd,"CP_CMIS_CON");
with this in, the code for the modeless dialog doesnt work
if i take it out then the code for the modeless dialog does work,
obviously i need it in, can ne1 help ???
si
|
|
|
|
|
si_69 wrote:
m_pWaitDlg->UpdateWindow();
There is no need to call UpdateWindow() here.
si_69 wrote:
the code for the modeless dialog doesnt work
Define "doesnt work." Have you single-stepped through each line of code?
The code you've shown does not appear to do anything other than create a dialog object and then destroy it. I can't imagine it being on the screen any longer than a quick flash, if that long. The last time I used one, there was some (lengthy) processing going on in between the calls to ShowWindow() and DestroyWindow() .
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&select=857875&df=100&fr=101#xx857875xx
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Does anyone know how to detect a CDatabase disonnection?
I'm inserting rows into a database and when it disconnects it throws a CDBException with return code of type 'SQL_ERROR'. This is the same error code for all SQL errors e.g. primary key violation etc.
I want to detect a disconnection, then attempt a reconnect but can't figure out how to specifically detect a disconnection?
Can anyone help?
|
|
|
|
|
What really happen when I convert my VS 6.0 (C++) project to a VS .NET project. May I then take advantage of some .NET “stuff”?
Are there any reason for me to start using VS .NET except for a nicer editor?
All tips are welcomed!
_____________________________
...and justice for all
APe
|
|
|
|
|
What really happen when I convert my VS 6.0 (C++) project to a VS .NET project. May I then take advantage of some .NET “stuff”?
Only if your existing project uses it, or else .NET won't be called.
Are there any reason for me to start using VS .NET except for a nicer editor?
My personal opinion,
Pros: Better compiler and linker (claimed that the executables generated by VC7 run faster than VC6 in Dr Dobb's Journal), better STL conformance, upgraded debugger.
Cons: Slower interface compares to VC6, no more class wizard.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Anthony_Yio wrote:
no more class wizard
I've found that irritating too. Anyway, I guess I still can do all that class-wisard did in some other way?
_____________________________
...and justice for all
APe
|
|
|
|
|
Anyway, I guess I still can do all that class-wisard did in some other way?
Of course, there are. Just that the functions are not in the same place. A few ways to access the class wizard functions. In VS 2003, I am not sure of others. One, is via your properties window - control event button when you have selected your resources, this allow you to select the event handler you need.
and second, is by right click on your resources. You will notice, Add Varible or Add Event Handler menu enabled.
For more details, check out their dynamic help.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Good to hear! Tahnks
_____________________________
...and justice for all
APe
|
|
|
|
|
Hi,
I would like to connect do a DSN (data source name) through my code in C++, but I don't want to write the UserName and Password in my code: how can I do??
Here it is my code:
static bool IsSubscribed(SQLCHAR Account[], bool& subscription, bool& warning)
{
SQLHENV henv = NULL;
SQLHDBC hdbc = NULL;
SQLHSTMT hstmt = NULL;
SQLRETURN sRet;
PTSTR szDataSource = _T("DSN_NAME");
PTSTR szUID = _T("UserName");
PTSTR szPWD = _T("Password");
// Initialize the ODBC environment.
if (SQLAllocHandle(SQL_HANDLE_ENV, NULL, &henv) == SQL_ERROR)
{
WriteIntoFile("ERRORE Initialize the ODBC environment");
return false;
}
SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*) SQL_OV_ODBC3,SQL_IS_INTEGER);
// Allocate a connection handle and connect to the data source.
if (SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc) == SQL_ERROR)
{
WriteIntoFile("ERRORE Allocate a connection handle");
return false;
}
if (SQLConnect(hdbc, (SQLTCHAR*) szDataSource, SQL_NTS,
(SQLTCHAR*) szUID, SQL_NTS, (SQLTCHAR*) szPWD, SQL_NTS) == SQL_ERROR)
{
WriteIntoFile("ERRORE Connect to the DataSource");
return false;
}
// Get a statement handle and execute a Transact-SQL SELECT statement
if (SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt) == SQL_ERROR)
{
WriteIntoFile("ERRORE Get a statement handle and execute a Trans-SQL");
return false;
}
SQLINTEGER cbAccount = SQL_NTS;
// ? marks the input parameter.
sRet = SQLPrepare(hstmt, (SQLCHAR*) "{call spIsSubscribed(?)}", SQL_NTS);
// Bind the input parameter.
sRet = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR, 20, 0, Account, 0, &cbAccount);
if( (SQLExecute(hstmt)) == SQL_ERROR)
{
WriteIntoFile("ERRORE Execute");
return false;
}
bool sub;
SQLINTEGER cbSub;
bool warn;
SQLINTEGER cbWarning;
// Retrieve data from row set.
SQLBindCol(hstmt, 1, SQL_C_BIT, (SQLPOINTER) &sub, 0, &cbSub);
SQLBindCol(hstmt, 2, SQL_C_BIT, (SQLPOINTER) &warn, 0, &cbWarning);
sRet = SQLFetch(hstmt);
if(sRet != SQL_SUCCESS && sRet != SQL_SUCCESS_WITH_INFO)
{
WriteIntoFile("ERRORE Fetch");
return false;
}
subscription = sub;
warning = warn;
/* Clean up.*/
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
SQLDisconnect(hdbc);
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
SQLFreeHandle(SQL_HANDLE_ENV, henv);
return true;
}
|
|
|
|
|
Hi..
I don't have much time to see your code but
One thing u can do is supply coneection string...
that's very easy...
Use class CDatabase
CRecordset
or drive class from CRecordset & supply all information at creation time...
I'm in hurry...
so see..u later..
bye..
---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
Why not wrap all of that ODBC nastiness into a class? I have been using the same ODBC classes for about 8 years now, and never had a problem. If you want the classes, shoot me an email.
onwards and upwards...
|
|
|
|
|
Hello,
I have class defined somethig like this :
class CAaa
{
...
CString m_str;
void Set();
}
CAaa::Set()
{
CString tmp;
m_str = tmp;
}
It's more complicated class, but this is the most important part.
Destructor of CAaa will crash the application in CString destructer,
which shows ASSERT in debug mode that it can't free the memory, because it's not valid memory block.
I found out that this won't happend when i use
m_str = (LPCSTR)tmp;
insead of
m_str = tmp;
Why the second thing is not working ? I know that there's only reference increment in second case, and copying of all data in first case,
but why doesn't the reference counting work correctly ?
Is this bad practice to assign member CString value of local CString in function ?
Thanks
rrrado
|
|
|
|
|
How is the CAaa object being created, and Set() being called.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks for reply !
I don't know whether this is important, but there's list oc Caa :
typedef CArray<CAaa,CAaa&> CAaaArray
class anotherClass
{
void SomeFunc();
CAaaArray m_array;
}
CAaa::SomeFunc()
{
CAaa *aaa;
for (int i=0; i<m_array->GetSize(); i++)
{
aaa = &m_array->GetAt(i);
....
aaa->Set();
}
}
Another weird thing is that for each item in this loop also destructor of CAaa is called, but it's probably because od GetAt returning temporary object created with default copy constructor, which is destroyed at the end of the loop ... I'll have to figure out whether creating of temporary CAaa object isn't problem ....
rrrado
|
|
|
|
|
Sorry
typedef CArray<CAaa,CAaa&> CAaaArray;
rrrado
|
|
|
|
|
I assume you typed these code snippets in rather than copying/pasting them directory from your project. I had to make some changes just to get them to compile. Here is what I have that produces no errors:
class CAaa
{
CString m_str;
public:
CAaa();
~CAaa();
void Set();
};
void CAaa::Set()
{
CString tmp;
m_str = tmp;
}
typedef CArray<CAaa *, CAaa *> CAaaArray;
class anotherClass
{
CAaaArray m_array;
public:
anotherClass();
~anotherClass()
{
CAaa *aaa;
for (int i = 0; i < m_array.GetSize(); i++)
{
aaa = m_array.GetAt(i);
delete aaa;
}
}
void SomeFunc();
void add();
};
void anotherClass::add()
{
CAaa *aaa = new CAaa;
m_array.Add(aaa);
}
void anotherClass::SomeFunc()
{
CAaa *aaa;
for (int i = 0; i < m_array.GetSize(); i++)
{
aaa = m_array.GetAt(i);
aaa->Set();
}
}
...
anotherClass ac;
ac.add();
ac.SomeFunc(); How does it compare to what you have?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yes it would be too big to paste here original classes.
You've used array of pointers, I used array of objects.
So there is different constructing/destructing objkects in array,
it's maybe the biggest difference.
I've posted original array typedef in previous message
rrrado
|
|
|
|
|
ok I've created new project where this also happend
http://rrrado.szm.sk/aaa.zip
just compile and click twice at the button1
Thank you !
rrrado
|
|
|
|
|
This works
for (i=0; i<20; i++)
{
(m_array.GetAt(0)).Set();
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Did you mean (m_array.GetAt(i)).Set(); ?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
No Check the code
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Technically, yes, but 0 was used in the example so it just propagated to the reply. In any case, whether 0 or i was used was not the cause of the problem.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
It depends on the application, maybe he just wanted to call Set on the first object 20 time.
That's why i suggested that he checks the code.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Since you are adding a CEmail reference to the CEmailArray , you need to do the same thing (i.e., you can't use a pointer, unless new was called first) when accessing the array. So just change the call to GetAt() to:
CEmail eml;
...
eml = m_array.GetAt(0);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thank you all, guys !
GetAt(0) was typo, it had to be (i) but it's not important.
I'm curious, why my solution did not work. Maybe temporary object
returned from GetAt was destroyed before I called Set().
But anyway, I found GetAt() unusable, since I need to change objects in array,
not some temporary object returned by GetAt().
I don't understand why GetAt is designed to return copy of the object instead of reference/pointer to object in the array,
I had to use this :
for (i=0; i<20; i++)
{
m_array[i].Set();
}
AfxMessageBox(m_array.GetAt(0).m_data);
The dialog in GetAt case shows "aaa", in operator[] case returns correct result "hello"
But operator[] is also defined like returning reference, or constant, returning copy, I don't have a clue which type the compiler will choose,
I'm happy that correct type was choosen in my code.
Thanks !
rrrado
|
|
|
|
|