|
Yes, Rajesh I have checked the return code is -11072.. I am not able to find any related document for this error code
Any help is appreciate..
Thanks,
Ashish
asdsa
|
|
|
|
|
I'd probably try switch ing the return value to one of the values documented.
The possible return values documented are: SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA, SQL_STILL_EXECUTING, SQL_ERROR, SQL_INVALID_HANDLE.
Or you could look up the definitions of these return values to see if any of these are defined as -11072.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Showing a relevant piece of code here might make things easier too.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
// NumRowsFetched.
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_BIND_TYPE, sizeof(ORDERINFO), 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE, ROW_ARRAY_SIZE, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_STATUS_PTR, RowStatusArray, 0);
SQLSetStmtAttr(hstmt, SQL_ATTR_ROWS_FETCHED_PTR, &NumRowsFetched, 0);
// Bind elements of the first structure in the array to the OrderID,
// SalesPerson, and Status columns.
SQLBindCol(hstmt, 1, SQL_C_ULONG, &OrderInfoArray[0].OrderID, 0, &OrderInfoArray[0].OrderIDInd);
SQLBindCol(hstmt, 2, SQL_C_CHAR, OrderInfoArray[0].SalesPerson,
sizeof(OrderInfoArray[0].SalesPerson),
&OrderInfoArray[0].SalesPersonLenOrInd);
SQLBindCol(hstmt, 3, SQL_C_CHAR, OrderInfoArray[0].Status,
sizeof(OrderInfoArray[0].Status), &OrderInfoArray[0].StatusLenOrInd);
// Execute a statement to retrieve rows from the Orders table.
SQLExecDirect(hstmt, "SELECT OrderID, SalesPerson, Status FROM Orders", SQL_NTS);
// Fetch up to the rowset size number of rows at a time. Print the actual
// number of rows fetched; this number is returned in NumRowsFetched.
// Check the row status array to print only those rows successfully
// fetched. Code to check if rc equals SQL_SUCCESS_WITH_INFO or
// SQL_ERRORnot shown.
while ((rc = SQLFetchScroll(hstmt,SQL_FETCH_NEXT,0)) != SQL_NO_DATA) {
asdsa
|
|
|
|
|
So, you've pasted here some code from MSDN[^].
If you're trying that sample mentioned in MSDN, do you have a replica of that database on your DB server?
How many iterations does the loop run, and what is the value that the call returns each time? And if it's that integer value you mentioned earlier, have you tried looking up the header files to see which valid return type is defined as that number? Please try this, and tell me what you find.
And in case you just pasted some random code from MSDN here in the hope that I'll setup a database here and do all the work to figure out what things could go wrong, ... I really don't have to be doing this at 3AM, you know?
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Hey there,
I have a function called,
App 1:
void GetImage(CImage * img)
{
//Pass &img over socket to another app
}
App 2:
void DisplayImage()
{
CImage * pImg = &img;
}
Is it possible to pass a class pointer as memory buffer across the socket?
The above code is just an example. My question in general is, whether it's possible to pass any Classes pointer as a memory buffer across sockets.
UPDATE:
This is within same process. In that case can i simply pass the pointer over socket?
Another catch here is, i need to encode all the data in a XML format before sending across the socket.
C++ Code:
CImage *pImage; //pImage hold the data
Inside XML:
<param />&pImage
Can i do like this?
Thanks
modified 15-Oct-13 12:48pm.
|
|
|
|
|
Don Guy wrote: My question in general is, whether it's possible to pass any Classes pointer as
a memory buffer across sockets
That depends. Are you passing it between different processes? If so, then the pointer will have no meaning in the context of the receiving process.
Remember that each process has its own allocation of memory that is separate from every other process. Therefore a memory pointer has no meaning outside its own process.
However, you could send the object itself through a process of serialization: http://msdn.microsoft.com/en-us/library/6bz744w8.aspx[^]
The difficult we do right away...
...the impossible takes slightly longer.
modified 14-Oct-13 20:49pm.
|
|
|
|
|
This is the good solution but "serialization" is usually a blurry word for beginners, I try to give OP a bit of help about serialization. Serialization is the process of converting one or more objects into a self contained piece of data that is self-contained/independent of the volatile state of your program. You do serialization for example when you save out a document into a file. The document data is self-contained and independent of the volatile state of your program because you can perfectly load it back to your program even after a program restart (that causes total loss of volatile state info). When you serialize you don't necessarily have to save the data into a file, instead you can send it over the network to another process that can "load" (deserialize) this data by creating objects that contain the same information from which the serialized data was created in the first process. Of course the pointerss to the objects will be probably different but the connection between the objects and their state variables can be identical.
|
|
|
|
|
Don Guy wrote: Is it possible to pass a class pointer as memory buffer across the socket?
Of course you can. But your application will crash, acchieve nothing and be completely useless.
You can pass the entire class if you want, and all referenced memory. And the other end must know about that class, and all the funcitons is contains.
|
|
|
|
|
Socket is just an unstructured byte stream, so you can certainly pass the pointer address as bytes on to other end. You will have to marshal pointer into bytes @ sending end and unmarshal it back to pointer at receiving end. To unmarshal, the receiver must either share the same address space as the sender or be provided a proxy to the same address space.
Oh, does this start to sound like Remoting?
Yep, that is what this is. Remoting does provide means to make a process function pointers visible to another process and Remoting does involve Sockets and passing of pointers to class. (Okay Okay, they're called reference)
So, Study Remoting !!.
|
|
|
|
|
Sockets are just one of the many ways to communicate, especially across processes. It's technically possible to pass any pointer using a socket without regards to what it's pointing to.
But if you pass a raw pointer from one process to another (using whatever mechanism, not just sockets), it immediately becomes meaningless because pointers are not portable across processes.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
As others have stated, you could pass pointers, but they would be meaningless to the other program since he can't access the memory addresses of the other exe (unless, it's "shared memory", continue reading). Your best bet would be to either transfer all the bytes of the image being referenced (or object, using serialization or other similar methods) or if both programs are local, let the client know where to find the image.
One common form of inter-process communications (IPC) is using "shared memory"[^]. In this case, one application would set up a shared memory pool that others can access. This is typically done for applications that need to work extremely fast (and all have direct access to the shared memory location) and don't want the overhead (or need the flexibility) of other IPC options (such as sockets or pipes).
|
|
|
|
|
UPDATE:
This is within same process. In that case can i simply pass the pointer over socket?
Another catch here is, i need to encode all the data in a XML format before sending across the socket.
C++ Code:
CImage *pImage; //pImage hold the data
Inside XML:
&pImage
Can i do like this?
|
|
|
|
|
If it's within the same application, then yes... but if you're within the same application, why are you using a socket at all?
Sockets are used to enable communications across multiple applications, not within the same application (you could but that doesn't mean you should, it's a lot of overhead for nothing).
|
|
|
|
|
I am unsure why are you using sockets, and I feel that there may be better options to choose from if you're having just one process.
If you could explain the situation with the required information (see this post[^] for help on what information to include in your question), someone here might be able to offer you a good alternative.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
It's very interesting.
In my own opinion, it is possible but you need something.
First, Receiver process have to open Sender process(use OpenProcess api with PROCESS_VM_READ) with memory access authority.
Second, Sender process have to allocate class instance on allocated memory located on it's own process memory(I don't know about it but if you use Google, it will appears).
Solving these problems may be difficult and complicated but it is possible, I think.
|
|
|
|
|
Oh yeah, watch out for endian ness.
|
|
|
|
|
HI,
Can anyone help me to find out any sample application to export the CListView data or GridView data into Excel or .CSV format using MFC
Thanks
ASH
|
|
|
|
|
Go to the articles section and search there, you will find many suggestions.
Veni, vidi, abiit domum
|
|
|
|
|
How is the CListView populated? If you have access to the code that does this, then you could export to a CSV from there.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Hi Rajesh,
Any sample code is there? It will be gr8 if you can share.
Thanks,
sma
|
|
|
|
|
I don't have a sample code with me to share, but I will need to write it. However, that takes time and I'll do it if I see that you've put all the efforts that you can.
It will be easier for you to try my suggestion and come back here with specific problems that you encounter during your attempt.
Now to answer it, do you have the code which populates this list view? If so, you could easily insert code into in there to export this same data to a .CSV file.
If not that, you could also read the values off the list view and then export it to CSV. Where exactly are you stuck?
Take one step at a time, and I'll help you through it if you need.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
I have the code which will insert values into list view..Only I need to read the data from list view and export it to excel.
Thanks in Advance
|
|
|
|
|
If I'm missing something here, please correct me.
If you've the code which is inserting the actual values, you could use that same code to create a .CSV file, right? Why do you have to write into a list, and read the same data from the list again?
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
My problem is to how to open the .CSV file and how to write the data into it..
Any sample is appreciated..
Thanks for your reply..
|
|
|
|
|