|
hi friend!
To add CDAORecordset class, create a new class from class wizard.
Type the Class name in the Name dialog box (e.g. CCEmp_Recset) and select the Base class as CDAORecordset.
Open the Emp_Dlg header file and add the following codings:
class CEmp_Recset;
with in the CEmp_Dlg class add the pointer variable
CEmp_Recset *m_set;
Add the member function in as
void Emp_Getset( ) for Receiving data from the table and transferred to dialog box.
void Emp_Setget( ) for transferring the data from the Dialog to table.
type the following coding on OnInitDialog( ) Function:
m_set = new CEmp_Recset();
m_set->Open();
Emp_Getset();
Type the following coding with in the function
void CEmp_Dlg::Emp_Getset()
{
m_ac_no = m_set->m_ac_no;
m_bank_name = m_set->m_bank_name;
m_bank_code = m_set->m_bank_code;
m_micr_no = m_set->m_micr_no;
m_remark = m_set->m_remark;
UpdateData(FALSE);
}
void CEmp_Dlg::EmpSetget()
{
UpdateData(TRUE);
m_set->m_ac_no = m_ac_no;
m_set->m_bank_name = m_bank_name;
m_set->m_bank_code = m_bank_code;
m_set->m_micr_no = m_micr_no;
m_set->m_remark = m_remark;
}
void CEmp_Det_Dlg::OnClickBtnMfisrt()
{
// TODO: Add your control notification handler code here
mset->MoveFirst();
Emp_Getset();
}
void CEmp_Det_Dlg::OnClickBtnMnext()
{
// TODO: Add your control notification handler code here
if(mset->IsEOF())
{
MessageBox("Reached at EOF()");
}
else
{
mset->MoveNext();
Emp_Getset();
}
}
void CEmp_Det_Dlg::OnClickBtnMprev()
{
// TODO: Add your control notification handler code here
if(mset->IsBOF())
{
MessageBox("Reached at BOF()");
}
else
{
mset->MovePrevious();
Emp_Getset();
}
}
void CEmp_Det_Dlg::OnClickBtnMlast()
{
// TODO: Add your control notification handler code here
mset->MoveLast();
Emp_Getset();
}
pls mail me if u need any help i will send a sample project..
AK
|
|
|
|
|
hero1995 wrote: hey, how can change these code in CDaoDatabase...
Why are you wanting to change CDaoDatabase code? It would be easier to just derive a class from CDaoDatabase . Take advantage of the virtual methods to supply your specific code.
"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
|
|
|
|
|
Hello, could somebody help me in sending and receiving a struct via winsock?
Do I have to allocate memory for the struct before sending/receiving?
How can I properly access the members of the structure after receiving?
Any help would be appreciated... bye
(I'm using VC++ 6 and Winsock 2 on asynchronous TCP socket)
|
|
|
|
|
sockets only understand bytes.
To send a struct you send it as a stream of bytes.
To get a pointer to the struct use the "address of" operator (&)
You'll need to cast this to a char* for some socket operations.
For the length of the struct (in bytes), use the sizeof operator.
When you receive the number of bytes equal to the sizeof the struct, you can cast a pointer to
those bytes into a struct pointer or just receive the bytes directly into a struct object.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: sockets only understand bytes.
To send a struct you send it as a stream of bytes.
To get a pointer to the struct use the "address of" operator (&)
You'll need to cast this to a char* for some socket operations.
For the length of the struct (in bytes), use the sizeof operator.
When you receive the number of bytes equal to the sizeof the struct, you can cast a pointer to
those bytes into a struct pointer or just receive the bytes directly into a struct object.
Thanks for your reply, but it still doesn't work, when I try to pop up a MessageBox showing a member of the received struct the client just crashes...
So what am I doing wrong? I'll post some code...
This is the struct, it's common for both the client and the server, of course:
<br />
typedef struct DATASTRUCT {<br />
<br />
char* sParam1;<br />
};<br />
This is the server side. It basically sends a string to the client when a connection is established:
<br />
struct DATASTRUCT ServerResponse;<br />
ServerResponse.sParam1 = "Welcome to the Server";<br />
send(sckConnection, (char*)&ServerResponse, sizeof(ServerResponse), 0);<br />
And this is the client side, where the incoming data is processed:
<br />
char* inBuffer = (char*)malloc(2048);<br />
int nRecv = recv(sckClient, inBuffer, 2048, 0);<br />
<br />
if ( nRecv == sizeof(DATASTRUCT*) )<br />
{<br />
DATASTRUCT IncomingData; <br />
IncomingData = (DATASTRUCT*)inBuffer;<br />
MessageBox(hWnd, IncomingData->sParam1, "incoming data", MB_OK);<br />
}<br />
I can't manage to access the sParam1 member, sometimes it returns a couple of bytes, sometimes an empty memory block... what I'm doing wrong? I don't want to use IPCMSG!
Thanks for your attention...bye
|
|
|
|
|
deerhunter89 wrote: typedef struct DATASTRUCT {
char* sParam1;
};
Make sure you send the actual data via the network (and NOT just a pointer)... for example:
enum { DATA_BUFFER_SIZE = 1024 };<br />
typedef struct DATASTRUCT {<br />
char param1[DATA_BUFFER_SIZE];<br />
};
Before sending the struct you would have to gather the data you want to send and copy it into the struct, param1 can hold maximum 1024 characters now (that would be equal to maximum c-string length of 1023 plus Null terminator).
Be aware that when sending e.g. numbers over the network that different platforms use different memory organisations (little/big endian[^]) and you might want to do some conversions.
Hope it helps
|
|
|
|
|
the string now arrives to the client, but it's truncated, only the first four bytes of it are shown, the rest are junk characters that consist in the buffer I think... can you guys tell me how can I properly read the data in the buffer and then cast the buffer to the struct?
|
|
|
|
|
If the string argument is a LPCSTR you could use the following example code on server side...
class CServerSocket<br />
{<br />
enum { DATA_BUFFER_SIZE = 1024 };<br />
struct DATASTRUCT {<br />
char param1[DATA_BUFFER_SIZE];<br />
char param2[DATA_BUFFER_SIZE];<br />
};<br />
};<br />
<br />
const char* SERVER_STR1 = "Welcome to the Server";<br />
const char* SERVER_STR2 = "The weather is fine today";<br />
<br />
CServerSocket::SendResponse(SOCKET sckConnection)<br />
{<br />
DATASTRUCT serverResponse<br />
strncpy(serverResponse.param1, SERVER_STR1, DATA_BUFFER_SIZE);<br />
strncpy(serverResponse.param2, SERVER_STR2, DATA_BUFFER_SIZE);<br />
send(sckConnection, (const char*)&serverResponse, sizeof(serverResponse), 0);<br />
}
Hope it helps
PS: The implementation would be different if you work with UNICODE strings.
|
|
|
|
|
Now everything works perfectly!! Thanks for your help, I've had to fight for 4 days to get the program working bye
|
|
|
|
|
As Moak stated, you generally can't send a pointer. A pointer points to data in the sending
process' address space and will be meaningless at the receive end unless the receiver is the same
process.
To send data pointed to by a pointer, some serialization method is generally used (to serialize
the data pointed to into a stream of bytes).
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
deerhunter89 wrote: char* inBuffer = (char*)malloc(2048);
int nRecv = recv(sckClient, inBuffer, 2048, 0);
if ( nRecv == sizeof(DATASTRUCT*) )
{
DATASTRUCT IncomingData;
IncomingData = (DATASTRUCT*)inBuffer;
MessageBox(hWnd, IncomingData->sParam1, "incoming data", MB_OK);
}
Unfortunately this code has some problems (and a memory leak):
a) TCP is a stream oriented protocol and you may not receive data chunks in exact the same size as they have been sent out, even if your code above works in the LAN it will fail with peers on the Internet. What you need to do in your client: collect all incoming data in a buffer, when you have enough data collected process the buffer.
b) The above code tests if you have 4 bytes of the data struct (a pointer has the size of 4 bytes on 32bit architectures). I suggest to collect incoming data until enough data was received to get a full 'DATASTRUCT' (move any possible "left overs" to the beginning of the buffer)... e.g. if(nBytesCollected >= sizeof(DATASTRUCT)) { ProcessData(m_buffer); UpdateReceiveBuffer(); }
|
|
|
|
|
// your app
#pragma pack(1)
typedef struct IpcMsg{
int iMessageServer;
int iMessageType;
int iSource;
int iRecipient;
int iMessage;
long iCircuit;
long iPartnerCircuit;
int iAutomataId;
int iCardTimeLeft;
int iAck;
char cTxt[128];
}IPCMSG;
IPCMSG Msg;
//socket part
send(m_ClientSocket, (char*)&Msg, sizeof(Msg), 0);
case FD_READ :
ZeroMemory(&Msg, sizeof(Msg));
recv(sock, (char*)&Msg, sizeof(Msg), 0);
ParcelMessage(Msg);
break;
|
|
|
|
|
my purpose is to copy selected row in a database. Error is: two few parameter.Expected1.what's wrong
void CReadDBDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CString strText;
CString strSQL;
CDaoDatabase db;
db.Open("D:\\copyktt.mdb");
CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_ListControl);
ASSERT(pListCtrl != NULL);
POSITION pos = pListCtrl->GetFirstSelectedItemPosition();
if (pos == NULL)
TRACE0("No items were selected!\n");
else
{
while (pos)
{
int nItem = pListCtrl->GetNextSelectedItem(pos);
TRACE1("Item %d was selected!\n", nItem);
// you could do your own processing on nItem here
strText = pListCtrl->GetItemText(nItem,0);
// m_cedit.SetWindowText(strText);
strSQL.Format("INSERT INTO Table6 SELECT * FROM Table3 IN 'C:\\ktt.mdb' WHERE MyField = %s",strText);
db.Execute(strSQL);
}
}
|
|
|
|
|
I feel the problem is with Format function. Instead of embedding the datbase path directly why can't you try with replacing the text with %s and pass the value as a seperate parameter (C:\\ktt.mdb).
|
|
|
|
|
hero1995 wrote: db.Execute(strSQL);
What is the exact value of strSQL at this point?
"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
|
|
|
|
|
hi!
what is the equivalent of "jmp far" in Hex value? or the equivalent of other instructions
for example: the equivalent of "nop" instruction is "0x90" in Hex Value
please help me
Zo.Naderi-Iran
|
|
|
|
|
Well dear I dont think anybody remembers these values.
I can suggest you to get Intel Processors by Berry B. Brey and get complete hex codes for all.
Hang on a sec!
Try debug utility i will try too.....
Spread wat u Know!
|
|
|
|
|
jmp far EA
jmp EB
Spread wat u Know!
|
|
|
|
|
Thank you, but i don't remember these (codes), i want to use these somewhen.
is there an article or a book, that it lists this hex codes?
Zo.Naderi-Iran
|
|
|
|
|
|
Thank you!
i read these, and i ask my problems;)
Zo.Naderi-Iran
|
|
|
|
|
Hello all ,
i want to know, does worker thread and ui thread returns a value.
And if it returns a value in what form does it return a value.....
thanks in advance
|
|
|
|
|
In Win32 you exit a thread using the ExitThread function; its sole argument is the return code of the thread. The return code is accessed with the GetExitCodeThread function. If you're using a library to manage the threading then you'll have to consult its documentation or include more information in your question.
Steve
|
|
|
|
|
hi
how do i open a new property sheet on click of a page on old property sheet.
|
|
|
|
|
Just as you create the first one. Is there some problem that you are facing, can you explain something more on this scenario?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|