|
If you're using MFC , this article [^] (from the competitors... ) may help.
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]
|
|
|
|
|
Hi,
The following sample failed to create the DSN,
void main()
{
//As my DB path will change frequently i am using this method.
bool aDSNCreated = false;
char temp[MAX_PATH];
sprintf(temp,"DSN=SAMPLE\0DBQ=D:\\SAMPLE.mdb\0");
aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, "Microsoft Access Driver (*.mdb)\0", temp);
printf("%d",aDSNCreated );
}
whereas when I execute the below code; it execute successfully.Can anyone help in this why its happening?
void main()
{
bool aDSNCreated = false;
aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, "Microsoft Access Driver(*.mdb)\0","DSN=SAMPLE\0DBQ=D:\\SAMPLE.mdb\0");
printf("%d",aDSNCreated );
}
|
|
|
|
|
DurgaDevi_hr wrote: "Microsoft Access Driver(*.mdb)\0","DSN=SAMPLE\0DBQ=D:\\SAMPLE.mdb\0"
Interesting string format with a double Null-Terminator[^], what were they thinking?
The extra Null-Terminator will cause problems with most C-Runtime string functions.
Have a look at SQLConfigDataSource attributes with variables[^], does this help?
/M
|
|
|
|
|
Hi Moak,
I tried the logic as specified in the link.
It worked fine. Thanks for that.
But can u tell me, why SQLConfigDataSource() parameter alone is accepting the null terminator string?
Any idea about that?
|
|
|
|
|
DurgaDevi_hr wrote: But can u tell me, why SQLConfigDataSource() parameter alone is accepting the null terminator string?
In a nutshell, the SQLConfigDataSource() uses a strange string format and with a literal text string this is fortunately not a problem (your second example code). But when you use string functions such as sprintf/strcpy/strlen they will stop at the first Null-Terminator. For example "bla\0fasel\0" would be copied only to the the first \0 and becomes "bla\0" . You can try it in the debugger.
modified on Monday, December 14, 2009 7:53 AM
|
|
|
|
|
|
DurgaDevi_hr wrote: The following sample failed to create the DSN,
So then why aren't you calling SQLInstallerError() to find out why?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi all,
I have developed a SDI. It is divided into two parts using a splitter i)simple view ii) another is a dialog(derived from CFormView).
My problem is, whenever i resizing the dialog, all static text and controls are erased and redrawing. How can i stop it?
Thanks to all
|
|
|
|
|
can you try WS_CLIPCHILDREN[^] style?
-Sarath.
Rate the answers and close your posts if it's answered
|
|
|
|
|
Hi...
I am doing a MFC Applicaton.
That is Multiple Document and Base class is CView Class. While i am running the program a white color window is opening. I need to change the white colour window to Block colour window.
Any one have idea, how to convert the window color?
Any help will be appreciated.
Thanks...
G.Paulraj
|
|
|
|
|
Create a "Black Brush" that leave like the window (for example, make it a member of your View class) and retun its handle responding to the WM_ERASEBKGND message.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
where i have to erase? in OnDraw() method?
G.Paulraj
|
|
|
|
|
Paulraj G wrote: where i have to erase?
Er ... no. You don't "have to": windows does this before calling WM_PAINT that's handled by MFC via OnDraw() .
And does this using the brush that is returned by the WM_ERASEBKGD message, that - by default - is the brush of the WINDOWCLASSEXW structure registered by MFC when creating the very first window ... that is -in turn- the brush returned by GetSysColorBrush(COLOR_WINDOW) that's usually white.
Now, if you have another brush (whatever color or pattern you like) and you trap the WM_ERASEBKGD message (just add the appropriate ON_MESSAGE macro in the message map and define a congruent function) returning your brush, widows will erase with it, and than will call OnDraw().
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
I think you need to set this as the background brush either when your View class is registered (not sure how this is done in MFC but I guess you can find out) or perhaps in the OnCreate() override.
|
|
|
|
|
Hi,
pls let me know how to create a bitmap dynamically..and need to draw a rect on the bitmap...
|
|
|
|
|
|
im using MFC...how to create bitmap dynamically..
|
|
|
|
|
Please go through CreateBitmap()
|
|
|
|
|
|
i never used Imgtfy, good answer
Величие не Бога может быть недооценена.
|
|
|
|
|
Thanks. I don't want to use it either, but some people ask for it.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
CBitmap may be helpful for you [^]
Величие не Бога может быть недооценена.
|
|
|
|
|
go for GDI+ Bitmap.
you can easily draw rect on it.
|
|
|
|
|
Hi all
I am using Ms SQL Server 2005.I try to get all databases names of MSSQL.I am able to connect with mssql through this code.
#import ".\sqldmo.dll" no_namespace
#include "afxwin.h"
_SQLServer2Ptr spSQLServer;
CString str1="",str2="",str3="",m_MHOST="";
LPWSTR HOST;
HRESULT hr;
if SUCCEEDED(hr = CoInitialize(NULL))
{
try
{
if (SUCCEEDED(spSQLServer.CreateInstance(__uuidof(SQLServer2))))
{
try
{
HOST=(_bstr_t)m_MHOST;
spSQLServer->LoginSecure = TRUE;
spSQLServer->Connect((_bstr_t)m_MHOST);
str1.Format(_T("Connected to %s"), (LPTSTR) spSQLServer->Name);
}
catch(_com_error pCE)
{
str2.Format(_T("%s"),(TCHAR*)pCE.Description());
MessageBox(str2,"Message");
return ;
}
}
else
{
str3.Format(_T("Unable to create the SQL Server object.\n"));
}
}
catch(_com_error pCE)
{
str2.Format(_T("\n%s Error: %ld\r\n%s\r\n%s\r\n"),
(TCHAR*)pCE.Source(),
pCE.Error(),
(TCHAR*)pCE.Description(),
(TCHAR*)pCE.ErrorMessage());
AfxMessageBox(str2);
return;
}
}
else
{
str2.Format(_T("Call to CoInitialize failed.\n"));
}
i try to get database name through this way.
QueryResultsPtr Qry;
CString dbs="SELECT * FROM SYS.DATABASES";
Qry=spSQLServer->ExecuteWithResults((_bstr_t)dbs);
but i am not able to get database name.Please help me
|
|
|
|
|
Hi,
Before executing the query "SELECT * FROM SYS.DATABASES", execute this query "USE master" and try ur select query.
I think it will work.
|
|
|
|