|
I dont exactly know what you mean.
But i use a CFormView as View.
There is a Ressource Dialog with the textboxes.
So i create the view with the dialog ressource.
Thanks for your help
|
|
|
|
|
I'm not sure if this will improve the speed, but what I'm saying is that, instead of placing the 100 odd controls in the form view directly, place them in a new dialog and then place this dialog in the form view as a child dialog. The child dialog will need its border set to none.
«_Superman_»
|
|
|
|
|
Hi,
Is there any method to create a file of desired size whenever I create a file using CreateFile().
|
|
|
|
|
SetEndOfFile can be used to extend or truncate a file.
«_Superman_»
|
|
|
|
|
Hi,
I am using IShellFolder to create tree like explorer. I got the ITEMIDLIST
for all item but I am confused to add to ITEMIDLIST list into one. because Desktop is has empty ITEMIDLIST (Root Folder) then how to add Child (say My computer )ITEMIDLIST to parent(Desktop) ITEMIDLIST ?
|
|
|
|
|
This article[^] has code for a 'concatenate ITEMIDLISTs' function.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi All,
I am using an ActiveX control for Thermal Printing in my website.... It is working fine for most of the client but now it is causig am unarthodox problem....
Once the activex is installed... it prints the label for first time only but when I issues the command for second time... the website hangs...
Closing the browser and logging again solve the purpose but only for the first print command... for second print command it hangs.
please sugest what is causing the problem???
Thanks in advance,
Vishav
ce
|
|
|
|
|
Hi there.
I want to connect to SQL Server 2008 through my C++ code.
As of now, I am doing the same as below
HRESULT hr = S_OK;
hr = m_pConnection->Open(L"DRIVER={sql server};SERVER=Server_Name;Database=DB_Name;" L"UID=UserID; PWD=Password;", L"", L"", adOpenUnspecified);
But above call throws an exception.
FYI, I am using msado15.dll to establish the connection.
I have also tried...
hr = m_pConnection->Open(L"Driver={SQL Server};Server=Server_Name;Database=DB_Name;", L"UID=UserID;", L"PWD=Password;", adOpenUnspecified);
But I am at the same stage.
Please let me know, if I need to implement the same by any other way.
Thanks
PanB
|
|
|
|
|
Hows about you mention what exception gets thrown - that usually gives you information about what error's occurred. Also, what's the type of m_pConnection is?
Oh - and have you verified you can connect to the database through some other utility?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for the reply buddy.
m_pConnection is of _ConnectionPtr type. I am able to test the connection using Visual Studio's Server Explorer option.
I am getting an error "Invalid Connection"
Any pointers on this.
Just a question...Do you think that there is no problem with my connection string or I need some modification do be done?
PanB
|
|
|
|
|
May be very stupid questions but
1. Are you calling CoInitialize?
2. How did you create instance of m_pConnection?
3. Did you verify that m_pConnection is not null?
4. Did you try to catch the exception using _com_error catch block to get the exact description of the problem?
Regards,
Sandip.
|
|
|
|
|
Anyway, Its always good to ask questions.
1. Are you calling CoInitialize?
PanB> Yes, I have a call to ::CoInitialize(NULL); in the constructor itself.
2. How did you create instance of m_pConnection?
PanB> Its a public member in my class.
_ConnectionPtr m_pConnection;
and in the CDataAccessManager::OpenDB() fucntions, I am initializing the same.
3. Did you verify that m_pConnection is not null?
PanB> I think, that is what you are talking about. In the CTor... I am initializing and calling CreateInstance as below...
m_pConnection = NULL;
m_strConnection = _T("");
m_pConnection.CreateInstance(__uuidof(Connection));
Am I suppose to first allocate memory for the same? please sugegst.
4. Did you try to catch the exception using _com_error catch block to get the exact description of the problem?
PanB> Yes, I have something like...
try
{
hr = m_pConnection->Open(L"Driver={SQL Server};Server=Server_Name;Database=Database_Name;", L"UID=UserName;", L"PWD=Password;", adOpenUnspecified);
return hr == S_OK;
}
catch(_com_error &e)
{
dump_com_error(e);
return FALSE;
}
How can I get more information regarding the exception? Please sugegst that as well.
Thanks
PanB
|
|
|
|
|
As an exception I am getting...
{E_FAIL}
m_hresult E_FAIL
m_perrinfo 0x02228530
m_pszMsg 0x00000000 <bad ptr="">
Above info. may help you...
|
|
|
|
|
PankajB wrote: catch(_com_error &e)
{
dump_com_error(e);
return FALSE;
}
instead you can try
e.Description()
it returns _bstr_t that might explain what is causing exception.
Regards,
Sandip.
|
|
|
|
|
PankajB wrote: I am able to test the connection using Visual Studio's Server Explorer option.
If server explorer is able to connect using your connection string, that implies your connection string is valid.
PankajB wrote: m_pConnection is of _ConnectionPtr type
PankajB wrote: I am getting an error "Invalid Connection"
Looking at this article[^], you need to create the connection like this before opening it:
_ConnectionPtr m_pConn;
m_pConn.CreateInstance (__uuidof(Connection));
Maybe that's missing?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I already have that in the CTor Stuart.
|
|
|
|
|
Let me share full code with you.
ado2.h
#if !defined(AFX_ADO2_H_INCLUDED_)
#define AFX_ADO2_H_INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <afx.h>
#include <afxdisp.h>
#include <math.h>
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
CString IntToStr(int nVal);
CString LongToStr(long lVal);
CString ULongToStr(unsigned long ulVal);
CString DblToStr(double dblVal, int ndigits = 20);
CString DblToStr(float fltVal);
class CDataAccessManager
{
public:
CDataAccessManager()
{
::CoInitialize(NULL);
m_pConnection = NULL;
m_strConnection = _T("");
m_pConnection.CreateInstance(__uuidof(Connection));
}
virtual ~CDataAccessManager()
{
CloseDB();
m_pConnection.Release();
m_pConnection = NULL;
m_strConnection = _T("");
::CoUninitialize();
}
BOOL OpenDB(LPCTSTR lpstrConnection = _T(""), LPCTSTR lpstrUserID = _T(""), LPCTSTR lpstrPassword = _T(""));
_ConnectionPtr GetActiveConnection()
{return m_pConnection;};
BOOL Execute(LPCTSTR lpstrExec);
BOOL IsOpenDB();
void CloseDB();
void SetConnectionString(LPCTSTR lpstrConnection)
{m_strConnection = lpstrConnection;};
CString GetConnectionString()
{return m_strConnection;};
protected:
void dump_com_error(_com_error &e);
public:
_ConnectionPtr m_pConnection;
protected:
CString m_strConnection;
};
#endif //AFX_ADO2_H_INCLUDED_
ado2.cpp
#include "ado2.h"
CString IntToStr(int nVal)
{
CString strRet;
char buff[10];
itoa(nVal, buff, 10);
strRet = buff;
return strRet;
}
CString LongToStr(long lVal)
{
CString strRet;
char buff[20];
ltoa(lVal, buff, 10);
strRet = buff;
return strRet;
}
CString ULongToStr(unsigned long ulVal)
{
CString strRet;
char buff[20];
ultoa(ulVal, buff, 10);
strRet = buff;
return strRet;
}
CString DblToStr(double dblVal, int ndigits)
{
CString strRet;
char buff[50];
_gcvt(dblVal, ndigits, buff);
strRet = buff;
return strRet;
}
CString DblToStr(float fltVal)
{
CString strRet;
char buff[50];
_gcvt(fltVal, 10, buff);
strRet = buff;
return strRet;
}
BOOL CDataAccessManager::OpenDB(LPCTSTR lpstrConnection, LPCTSTR lpstrUserID, LPCTSTR lpstrPassword)
{
HRESULT hr = S_OK;
if(IsOpenDB())
CloseDB();
if(lstrcmp(lpstrConnection, _T("")) != 0)
m_strConnection = lpstrConnection;
ASSERT(!m_strConnection.IsEmpty());
try
{
hr = m_pConnection->Open(L"DRIVER={sql server};SERVER=ASHISH-DB\ULXDBSERVER;Database=eDiscoveryDEV;" L"UID=edm; PWD=Password;", L"", L"", adOpenUnspecified);
return hr == S_OK;
}
catch(_com_error &e)
{
dump_com_error(e);
return FALSE;
}
}
BOOL CDataAccessManager::Execute(LPCTSTR lpstrExec)
{
ASSERT(m_pConnection != NULL);
ASSERT(lstrcmp(lpstrExec, _T("")) != 0);
_variant_t vRecords;
try
{
m_pConnection->CursorLocation = adUseClient;
m_pConnection->Execute(_bstr_t(lpstrExec), &vRecords, adExecuteNoRecords);
return TRUE;
}
catch(_com_error &e)
{
dump_com_error(e);
return FALSE;
}
}
BOOL CDataAccessManager::IsOpenDB()
{
if(m_pConnection )
return m_pConnection->GetState() != adStateClosed;
return FALSE;
}
void CDataAccessManager::CloseDB()
{
if(IsOpenDB())
m_pConnection->Close();
}
void CDataAccessManager::dump_com_error(_com_error &e)
{
}
DAL.cpp
#include "stdafx.h"
#include "ado2.h"
int _tmain(int argc, _TCHAR* argv[])
{
CDataAccessManager objDAL;
bool bSuccess = objDAL.OpenDB(_T("DRIVER={sql server};SERVER=ASHISH-DB\ULXDBSERVER;Database=LexCoreDB"), _T("edm"), _T("Password"));
return 0;
}
|
|
|
|
|
Any updates? Please provide some pointers to me so that I can proceed further. Thanks.
|
|
|
|
|
Hi all,
I have made a dialog based application in vc2008, i want to enable some keyboard shortcuts in my application like i have displayed a message box on button click event and if i press b that same dialog box should be displayed....
how can i do this???
Thanks in advance
|
|
|
|
|
To handle key pressings in dialogs, one should override PreTranslateMessage. It's MSG argument has the necessary information about pressed keys.
--
Arman
|
|
|
|
|
Add the ampersand [&] symbol before the desired letter in the button caption. For e.g for &Click, if you press Alt + C will run the code for Click button.
|
|
|
|
|
|
Hello,
I write the command to my device, the device responses immediately...
----
the code:
int begin;
While(1)
{
begin=GetTickCount();
WriteFile(...);
ReadFile(...);
TRACE(_T("The Tx-Rx Time is %d millisecond \r\n"), GetTickCount()-begin);
}
----
the output:
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 15 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 16 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 15 millisecond
------
It's good when spend 0 millisecond one loop...
But, as you can see above, every 3rd or 4th loop, the time spend is about 15 MS, it should be 0 MS, the ReadFile can't not get buffer data immediately...
Anyone met this problem before??
I need no delay in the loop...
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
The Tx-Rx Time is 0 millisecond
|
|
|
|
|
That's simply because windows is not a real-time operating system, so, it is possible that inside your loop another thread becomes active (which means that your thread won't be processed for a while, ending up with the delays).
The only way to "fix the problem" (which is not a problem in fact) is to use a real-time operating system (e.g. windows CE).
|
|
|
|
|
Dear Cédric Moonen:
It seems you are right, but the delay is in ReadFile (I tested it)... to wait buffer coming. If you are right, the delay will be in WriteFile or ReadFile. The context switch doesn't spend 15 MS (too long).
Thanks for you reply
|
|
|
|