473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem sending image from ASP to C++ application

Lee
I am having a problem returning an image that I got from SQL Server from
within an ASP page that got requested from a VC++ application.
Specifically, within my application, I make an HTTP call to my IIS server to
an ASP. The ASP then queries a SQL Server and the field that I want to
return from the resulting Recordset is an image. In the application, I then
make a call to receive the response from the web page but am having no luck
getting anything back. I have included both the ASP page and the code from
wthin the VC++ application. The part in the C++ code that I am debuggin and
noticing that nothing has returned is the while loop that is reading the
CInternetFile.

I hope this is enough for anyone that feels like helping me. In advance,
thanks very much.

Lee

ASP page:
<%
Dim objConn, objRS
Dim strConnect

Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTable = 2

Set objConn = Server.CreateObject ("ADODB.Connection")
Set objRS = Server.CreateObject ("ADODB.RecordSet")

objConn.Open "ODBC", "sa", ""

strFilter = "ID=" & Request.QueryString ("ID")

'Response.Write ( strFilter )
objRS.Filter = strFilter
objRS.Open "Pic", objConn, adOpenForwardOnly, adLockReadOnly, adCmdTable

If Not objRS.EOF Then
Response.Write ( objRS("Pic") )
Else
End If

objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing

%>
VC++ code:

void GetPicture(CString ID, unsigned long *ulPicLen, byte **bytePic)
{
CString strURL = "http://";
strURL += theApp.HostName;
strURL += "//GetPicture.asp";
strURL += "?ID=";
strURL += ID;

*ulPicLen = -1;
int nRetCode = 0;
DWORD dwAccessType = PRE_CONFIG_INTERNET_ACCESS;
const TCHAR szHeaders[] = _T("Accept: */*\r\nUser-Agent: PDA\r\n");
DWORD dwHttpRequestFlags = INTERNET_FLAG_NO_AUTO_REDIRECT;
BOOL bSuccess = TRUE;

CPerimeterSecurityHttpSession session(_T("HTTP"), (DWORD)this,
dwAccessType);
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;

// check to see if this is a reasonable URL
CString strServerName;
CString strObject;
INTERNET_PORT nPort;
DWORD dwServiceType;

if (!AfxParseURL(strURL, dwServiceType, strServerName, strObject, nPort) ||
dwServiceType != INTERNET_SERVICE_HTTP)
{
return;
}

session.EnableStatusCallback(TRUE);

pServer = session.GetHttpConnection(strServerName, nPort);

pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject,
NULL, (DWORD)this, NULL, NULL, dwHttpRequestFlags);
pFile->AddRequestHeaders(szHeaders);

pFile->SendRequest(NULL, 0, NULL, 0 );

DWORD dwRet;
pFile->QueryInfoStatusCode(dwRet);

if (dwRet == HTTP_STATUS_DENIED)
{
TRACE0 ("Access to the secured http site is denied!");
return;
}

int ndx = 0;
char *szWEBPage[MAX_WEBPAGE_SIZE+1];
char *sz[BUFFER_SIZE];
int iCurrentRead = 0;
int iTotalRead = 0;
pFile->SetReadBufferSize(BUFFER_SIZE*2);

while ( iCurrentRead = pFile->Read (sz, BUFFER_SIZE ) )
{
memcpy ( &szWEBPage[iTotalRead], sz, iCurrentRead );
iTotalRead += iCurrentRead;
}
*ulPicLen = iTotalRead;
*bytePic = new byte [ *ulPicLen ];
memcpy ( *bytePic, szWEBPage, *ulPicLen );

pFile->Close();
pServer->Close();

if (pFile != NULL)
delete pFile;
if (pServer != NULL)
delete pServer;
session.Close();
}
Jul 19 '05 #1
0 1830

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Lachlan Hunt | last post by:
Hi, I've been trying, but failing to work out what is causing Opera to render my drop down menu incorrectly on my site. http://www.lachy.id.au/ For some reason, there seems to be extra margin...
0
by: mackenzieduncan | last post by:
I have been trying to get an image to sit in the background behind my content div tag. I have nested two div's inside of another. The main div has three images in it, one at the top, one at the...
4
by: david | last post by:
hello, I have a client/server application. the server capture picture from webcam and send it to every client connected to it.the network part works good and the capture from webcam too. I...
1
by: staticfire | last post by:
Hi i am in need of help with an ajax related problem on my site. I've coded an active users list which shows the members and guests online. I'm sure you've all seen active user lists before, like the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.