|
I have built a cpp project into an exe file. When I run it it just shows for a moment and disappear. How can I make it seen untill i close the app.
Please help
Angalo
|
|
|
|
|
If your exe is a console application, add a getch() as the last statement in u r program. Don’t forget to include conio.h.
-- modified at 9:53 Saturday 27th May, 2006
|
|
|
|
|
Can you be more specific
whitesky
|
|
|
|
|
Hello.
I'm trying to figure out how to arrange the following code so that if a user were to enter a movie title, the SQL code in this program can accept a user-entered string and return the results. Right now, if I just put the name 'Vertigo', directly into the SQL code, it works perfect, but if I put the string sMovie into the SQL code, it just crashes the console.
Database name: VideoRental.mdb
Table name: Video
I only have three items in the table to test this code:
PROD_ID PROD_TITLE
10001 Psycho
11002 Vertigo
31001 Hostile
<br />
<br />
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \<br />
no_namespace rename("EOF", "EndOfFile")<br />
<br />
#include <stdio.h><br />
#include <iostream><br />
using namespace std;<br />
<br />
void main(void)<br />
{<br />
string sMovie = "Vertigo";<br />
<br />
CoInitialize(NULL);<br />
try <br />
{<br />
_RecordsetPtr pRst("ADODB.Recordset");<br />
_bstr_t strCnn("DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;DBQ=VideoRental.mdb");<br />
<br />
pRst->Open("SELECT * FROM [Video] WHERE [Video].[PROD_Title] = 'Vertigo';", strCnn, adOpenStatic, adLockReadOnly, adCmdText);<br />
<br />
pRst->MoveFirst();<br />
<br />
while (!pRst->EndOfFile) <br />
{<br />
cout<<(char*) ((_bstr_t) pRst->GetFields()->GetItem("PROD_ID")->GetValue())<< " ";<br />
cout<<(char*) ((_bstr_t) pRst->GetFields()->GetItem("PROD_TITLE")->GetValue())<< " ";<br />
pRst->MoveNext();<br />
}<br />
system("pause");<br />
pRst->Close();<br />
<br />
system("pause");<br />
<br />
}<br />
catch (_com_error &e)<br />
{<br />
cout<<(char*) e.Description();<br />
}<br />
<br />
::CoUninitialize();<br />
}<br />
|
|
|
|
|
You have to build the command string, using std::ostringstream is the easiest way to do this.
Dreamspeeder wrote: pRst->Open("SELECT * FROM [Video] WHERE [Video].[PROD_Title] = 'Vertigo';", strCnn, adOpenStatic, adLockReadOnly, adCmdText);
std::ostringstream SQLCommand;
SQLCommand << "SELECT * FROM [Video] WHERE [Video].PROD_Title = '" << sMovie << "';" << std::ends;
pRst->Open(SQLCommand.str().c_str(), strCnn, ...
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
HI all...
I'm looking for some good tutorials about develop visual c++ multi thread but with out using MFC.
I try Google but didn't find something really good that explain how to develop multi thread.
Someone can help ?
Thanks
|
|
|
|
|
|
See Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
Hey,
I've an application using a CTreeCtrl for navigation. When the user closes the application I want to save the selected item. I cannot use the CTreeCtrl::ItemData because several items hold the same data. Is there any way, to get an ID or a possition of the selected item?
Thanx for your help!
-- modified at 12:15 Friday 26th May, 2006
|
|
|
|
|
not easy
depends tree depth
One approach index.
Kuphryn
|
|
|
|
|
Walk up the nodes to the root building a path object/string whatever you need.
|
|
|
|
|
how can i implinent thereads in MFC what is the header file that i can use if anyone know plz let me know at noumanzaidi@hotmail.com
nomy
|
|
|
|
|
you can start a thread using MFC by calling AfxBeginThread function.
The function (pointer) poassing this function should be static if it is part of a class.
normally we will pass the object pointer to teh function to access the data of the class.
u can also pass global function as thread routine.
the function should prototyped as follows
UINT FxnName(LPVOID pParam )
i think it is better to use CreateThread function instead of calling AfxBeginThread.
See MSDN for more info.
SaRath
|
|
|
|
|
SaRath C wrote: i think it is better to use CreateThread function instead of calling AfxBeginThread.
MFC is not properly initialized for the thread context when CreateThread() is used.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
See example below
UINT MyThreadProc( LPVOID pParam )
{
CMyObject* pObject = (CMyObject*)pParam;
if (pObject == NULL ||
!pObject->IsKindOf(RUNTIME_CLASS(CMyObject)))
return 1; // if pObject is not valid
// do something with 'pObject'
return 0; // thread completed successfully
}
// inside a different function in the program
.
.
.
pNewObject = new CMyObject;
AfxBeginThread(MyThreadProc, pNewObject);
SaRath
|
|
|
|
|
|
|
I use a table named FDetails with 4 text fields and a datetime field named date in MSaccess
when insert values into table ising ado recordset obj I receive some syntax error
recordset->Open("INSERT INTO FDetails(name,path,duration,volume,date) VALUES('hello','location','duration','vol','12/12/2000')",connection.GetInterfacePtr(), ADODB::adOpenForwardOnly,ADODB::adLockReadOnly, ADODB::adCmdText);
any one know inserting date into table
|
|
|
|
|
GANsJob wrote: when insert values into table ising ado recordset obj I receive some syntax error
And that error would be what?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
the error is
syntax error in insert into statement
|
|
|
|
|
See here.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Try change the field name 'date' to 'date1'. If I remember correctly, date is a reserved word in ms access.
cheers..milton kb.
|
|
|
|
|
Hello All,
I am using a Win32 regular Dll . I want to call a function written in VB application using function pointers.
The snippet from Win32 dll is as follows:
typedef int (*pt2Function)(char*);
pt2Function Objectpt2Function;
EXPORT int PASCAL PassPtr(int (*pt2Func)(char*))
{
pt2Func("arun");
return 1;
}
The Snippet from VB Application is as follows:
Public Sub Callbackfuntion(ByVal str1 As String)
MsgBox "Callbackfuntion"
End Sub
x = PassPtr(VarPtr(Callbackfuntion))
This all results in the application crash....
Can anyone suggest me a solution how I can call this function??
Thanks in Advance
Arun Tayal
|
|
|
|
|
You cannt call a VB function from c++ without using COM, because all vb dlls are com components. SO the typical win32 dll function call approch using typedef wont work here. You cave to use
#import yourvbcomponent.dll <br />
<br />
CoInitilaize(NULL)
yourvbcomponentLib::_vbclassPtr clsPtr(yourvbcomponentLib::vbclass)
<br />
CString msg = "tst msg";<br />
BSTR bstr = msg.AllocSysString();<br />
clsPtr->Callbackfuntion(bstr);<br />
SysFreeString(bstr);<br />
cheers....milton.
|
|
|
|
|
Im trying somewhat simplest idea of sockets app using multicast.
Following is what SockApp1 does:
1) OnButtonCreate() creates the port, default OS assigned port. Create(0, SOCK_DGRAM)
m_pUDPSocket->Create(0, SOCK_DGRAM);
2) When OnButtonInitMulti() the mutlicast group(ip/port) is initialized.
memset(&m_addrMulti,0,sizeof(m_addrMulti));<br />
m_addrMulti.sin_family =AF_INET;<br />
m_addrMulti.sin_addr.s_addr =inet_addr(MULTIADDR);<br />
m_addrMulti.sin_port =htons(MULTIPORT);
3) When OnButtonSend()it sends the data to the group.
SendTo(m_sendBuffer, m_sendBuffer.GetLength(), <br />
(const SOCKADDR* )&m_addrMulti, sizeof(m_addrMulti));
SockApp2 with following buttons clicked:
1) OnButtonCreate() creates the port, default OS assigned port. Create(0, SOCK_DGRAM)
m_pUDPSocket->Create(0, SOCK_DGRAM);
2) OnButtonJoinMulti() joins the multicast group.
ip_mreq mreq;<br />
memset(&mreq, 0, sizeof(ip_mreq));<br />
mreq.imr_multiaddr.s_addr = inet_addr(MULTIADDR);<br />
mreq.imr_interface.s_addr = htonl(MULTIPORT);<br />
<br />
if(SOCKET_ERROR == SetSockOpt(IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)))<br />
{<br />
AfxMessageBox("Error: Unable to add membership");<br />
return -1;<br />
}
here...
#define MULTIADDR "224.0.1.129"<br />
#define MULTIPORT319 5009
Now, SockApp1, when i click onto the Send button, OnButtonSend() shud get called in which im doing the SendTo() thing. Uptill here the App1/App2 both are working fine, and the data is being sent successfully, this im sure.
The problem is, that SockApp2, which joined the group, is unable to receive the data being sent from SockApp1.
Now, SockApp1 and SockApp2 are actually a single app, called SockApp. I added SockApp1/2 names just for the clarity of the question and understanding.
At this moment, im just wondering... why SockApp2 is not receiving the data from SockApp1???
Any ideas why?
Best regards,
JT!
|
|
|
|