|
#ifdef _DEBUG
debugMethod();
debug1Method();
#else if _RELEASE
releaseMethod();
#else
AdvanceReleaeMethod();
#endif
Regards,
Paresh.
|
|
|
|
|
For doing this you need to know the concept of preprocessor directive
#IFDEF | #IFNDEF ConstantName
Commands
[#ELSE
Commands]
#ENDIF
if you know this you can do it by just defining a macro suppose _DEBUG_MODE
and put it in preprocessor defination of C++ in project properties under debug configuration.
and then define like this
class MyClass
{
#ifdef _DEBUG_MODE
debugMethod();
debug1Method();
#ELSE
releaseMethod()
#ENDIF
}
Regards,
Pankaj Sachdeva
"There is no future lies in any job"
"but"
"future lies in the person who holds the job"
|
|
|
|
|
How do i create an MS SQL database table during installation of an MFC application. how and where do i run the necessary SQL script??
I have created an installer using Visual Studio 2003.NET
|
|
|
|
|
yashveer wrote: create an MS SQL database table during installation of an MFC application
Can you more exaplain,please?
|
|
|
|
|
You can use SQLExecute("CREATE DATABASE...") for this.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I tried the following:
SQLHSTMT hstmt;<br />
SQLCHAR temp[]="CREATE TABLE [dbo].[Purchase]([PurchaseOrderID] [int] NOT NULL,[LineNumber] [smallint] NOT NULL)";<br />
<br />
SQLRETURN sql_ret;<br />
sql_ret=SQLPrepare(hstmt,temp,SQL_NTS);<br />
<br />
SQLExecute(hstmt);
It gives an error at line SQLprepare():
Unhandled exception in .exe(ODBC32.DLL): Access Denied
|
|
|
|
|
Next i tried this:
SQLHENV henv;<br />
SQLHDBC hdbc[10];<br />
SQLAllocEnv(&henv);<br />
SQLAllocConnect(henv,hdbc);<br />
SQLCHAR server[]="Rel";<br />
SQLCHAR uid[]="";<br />
SQLCHAR pwd[]="";<br />
SQLRETURN rc;<br />
rc=SQLConnect(*hdbc,server,SQL_NTS,uid,SQL_NTS,pwd,SQL_NTS);<br />
<br />
SQLHANDLE hstmt;<br />
SQLHANDLE hconn; <br />
SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt);<br />
<br />
SQLCHAR str[]="SELECT dat FROM transact1";<br />
rc=SQLExecDirect(hstmt,str,SQL_NTS);<br />
int i=0;
I m getting the same error on SQLExecDirect() line.
Unhandled exception:Access denied
|
|
|
|
|
What if you ommitted SQLPrepare() and SQLExecute() , and called SQLExecDirect(hstmt, temp, SQL_NTS) instead?
Of course, you've not shown us how you are calling SQLAllocHandle() , so it may be in error further upstream.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
I would suggest getting a "real" installer system! For example, Wise Installer (as of at last 4 years ago) was capable of installing databases and related items (SPs, views, users, logins, etc.) into an RDBMS.
Short of that, you can just create a little application that contains all of the SQL you need to deploy your entire schema and knows how to connect to your target RDBMS(es) and can execute the SQL. You can then have your installer launch it during installation (and during uninstallation for cleanup if necessary) to install the database for you.
One thing I did previously was to put the DB installation logic into the application itself, and the first time it ran and noticed the database was not in the specified RDBMS, it installed it. Sounds a bit kludgy, but it worked well for targeting multiple RDBMSes (QA, staging and production) from a single installation of the application.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James R. Twine wrote: One thing I did previously was to put the DB installation logic into the application itself,
and the first time it ran and noticed the database was not in the specified RDBMS,
it installed it. Sounds a bit kludgy...
Hmm. I still do that. I think having to have an install program is kludgy
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You said: you can just create a little application that contains all of the SQL you need to deploy your entire schema and knows how to connect to your target RDBMS(es) and can execute the SQL.
How can this be achieved?
I tried SQLPrepare() and SQLExecute()....Please see my reply to David Crow.
|
|
|
|
|
Thnks a lot every one!!!!
I have been able to create a database and a table programmatically
The error wasin the line
SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt);
I changed it to:
SQLAllocHandle(SQL_HANDLE_STMT,*hdbc,&hstmt);
|
|
|
|
|
Hi
I'm writing a program for parallel port communication (in Win X)P. I've used the code in http://www.codeproject.com/system/AsefPortAccess.asp as a guideline.
When running the program, the line "_outp(0x378, iByte);" gives an error. On debugging I tracked the error to the assembly code line "1022CC4B out dx,al" which gives the error "Unhandled exception in ParallelComm.exe (MSVCRTD.DLL): 0xC0000096: Privileged Instruction."
I'd appreciate it if someone could help me out here
mirispearl
|
|
|
|
|
I know this may come as a shocking suggestion, but have you tried asking your question about using the articles code ON THE ARTICLE'S FORUM? The author will see it, and is quite likely to respond. I see he answered the last question there.
You're hoping that someone here will go to the article, download or at least read it, then answer your question.
Under NT (which XP is), you can't talk directly to the hardware from user mode, but need to go via a device driver. I'm guessing that _outp is a wrapper function around some machine code that talks directly to the I/O. Have you tried using the debugger and looking inside the function?
Iain.
|
|
|
|
|
A user program doesn't have access to the hardware in Win NT and upwards.
Check out inpout32.dll, it will take care of the problem. It can be downloaded from a lot of places, just Google for "inpout32 download".
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
thanks
worked like a charm
|
|
|
|
|
I'm glad I could help you. Good luck and thanks for letting me know.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Can any body please send some good links on mSMQ with examples using VC++
Thanks
abhi
|
|
|
|
|
|
Have you Googled for such, or checked MSDN?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Pls help me solve it...
I got this error when I compile with VS 2005, pls help me.
------ Build started: Project: VLTKLib, Configuration: Debug Win32 ------
Compiling...
pHandle.cpp
Linking...
pHandle.obj : error LNK2028: unresolved token (0A000299) "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "public: void __thiscall VLTKLib::pHandle::setHandle(char *,char *)" (?setHandle@pHandle@VLTKLib@@$$FQAEXPAD0@Z)
pHandle.obj : error LNK2028: unresolved token (0A00029B) "extern "C" unsigned long __stdcall GetWindowThreadProcessId(struct HWND__ *,unsigned long *)" (?GetWindowThreadProcessId@@$$J18YGKPAUHWND__@@PAK@Z) referenced in function "public: void __thiscall VLTKLib::pHandle::setHandle(struct HWND__ *)" (?setHandle@pHandle@VLTKLib@@$$FQAEXPAUHWND__@@@Z)
pHandle.obj : error LNK2019: unresolved external symbol "extern "C" unsigned long __stdcall GetWindowThreadProcessId(struct HWND__ *,unsigned long *)" (?GetWindowThreadProcessId@@$$J18YGKPAUHWND__@@PAK@Z) referenced in function "public: void __thiscall VLTKLib::pHandle::setHandle(struct HWND__ *)" (?setHandle@pHandle@VLTKLib@@$$FQAEXPAUHWND__@@@Z)
pHandle.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "public: void __thiscall VLTKLib::pHandle::setHandle(char *,char *)" (?setHandle@pHandle@VLTKLib@@$$FQAEXPAD0@Z)
d:\workspace\VLTK\Debug\VLTKLib.dll : fatal error LNK1120: 4 unresolved externals
Build log was saved at "file://d:\workspace\VLTK\VLTKLib\Debug\BuildLog.htm"
VLTKLib - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
My class:
pHandle.h
#pragma once
#include <string>
#include <stdlib.h>
#include <Windows.h>
namespace VLTKLib
{
public class pHandle
{
private:
HANDLE hProcess;
public:
pHandle(void);
pHandle(HWND curWin);
pHandle(char *winClass, char *winTitle);
~pHandle(void);
void setHandle(HWND curWin);
void setHandle(char *winClass, char *winTitle);
void closeHandle();
long ReadInt(LPBYTE lpAddress);
short ReadWord(LPBYTE lpAddress);
char ReadChar(LPBYTE lpAddress);
char *ReadString(LPBYTE lpAddress, int szChar);
};
}
pHandle.cpp
#include "StdAfx.h"
#include "pHandle.h"
#include <string>
#include <stdlib.h>
#include <Windows.h>
namespace VLTKLib
{
pHandle::pHandle(void)
{
}
pHandle::pHandle(HWND curWin)
{
setHandle(curWin);
}
pHandle::pHandle(char *winClass=NULL, char *winTitle=NULL)
{
setHandle(winClass, winTitle);
}
pHandle::~pHandle(void)
{
CloseHandle(hProcess);
}
void pHandle::setHandle(HWND curWin)
{
DWORD dwProcessID;
::GetWindowThreadProcessId(curWin, &dwProcessID);
hProcess = OpenProcess(PROCESS_VM_READ|PROCESS_VM_WRITE , FALSE, dwProcessID);
if (!hProcess) {
return;
}
}
void pHandle::setHandle(char *winClass=NULL, char *winTitle=NULL)
{
HWND curWin = FindWindow((LPCWSTR)winClass,(LPCWSTR)winTitle);
setHandle(curWin);
}
}
Tks a lot.
-- modified at 2:36 Monday 20th August, 2007
|
|
|
|
|
Have you used /NODEFAULTLIB linker option , by accident ?
Prasad
MS MVP - VC++
|
|
|
|
|
How to check it? I did not change any thing.
Tks for your help.
|
|
|
|
|
Check Project setting-->configuration properties-->Input-->Ignore All default lib. set it to No if, if it is yes.
Prasad
MS MVP - VC++
|
|
|
|