vc扩展存储过程兼职 不用VC,直接用asp加存储过程就可以搞定http://community.csdn.net/Expert/topic/3960/3960021.xml?temp=.49844 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 extended proc + ASP#include "stdafx.h"#define DBNTWIN32#include <windows.h>//G:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Include\sqlfront.h#include <sqlfront.h>#include <sqldb.h>#include <srv.h>#include <sstream>#include <UrlMon.h>#pragma comment(lib,"urlmon.lib")#define XP_NOERROR 0#define XP_ERROR 1#define MAX_BINDTOKEN 256#define MAX_SERVER_ERROR 20000#define XP_HELLO_ERROR MAX_SERVER_ERROR+1//G:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Lib\opends60.lib//G:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Lib\ntwdblib.lib#pragma comment(lib,"opends60.lib")#pragma comment(lib,"Ntwdblib.lib")//need to download the following dlls//G:\Program Files\Microsoft SQL Server\80\Tools\Binn\OPENDS60.DLL//G:\Program Files\Microsoft SQL Server\80\Tools\Binn\ums.DLLextern "C" __declspec(dllexport) ULONG WINAPI __GetXpVersion(){ return ODS_VERSION;}extern "C" __declspec(dllexport) BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ){ return TRUE;}// send XP usage info to clientvoid printUsage (SRV_PROC *pSrvProc){ // usage: exec xp_call_asp_by_onega <@table_name input> <@record_id input> <@additional_info input> // Example: // exec xp_call_asp_by_onega 'table1',1,'for table1' //build by Onega at 2005/04/23 with VC2003, Windows 2003, SQLServer 2000 srv_sendmsg(pSrvProc, SRV_MSG_ERROR, XP_HELLO_ERROR, SRV_INFO, 1, NULL, 0, (DBUSMALLINT) __LINE__, "Usage: exec xp_call_asp_by_onega <@table_name input> <@record_id input> <@additional_info input>", SRV_NULLTERM); srv_senddone(pSrvProc, (SRV_DONE_ERROR | SRV_DONE_MORE), 0, 0);}// send szErrorMsg to clientvoid printError (SRV_PROC *pSrvProc, CHAR* szErrorMsg){ srv_sendmsg(pSrvProc, SRV_MSG_ERROR, XP_HELLO_ERROR, SRV_INFO, 1, NULL, 0, (DBUSMALLINT) __LINE__, szErrorMsg, SRV_NULLTERM); srv_senddone(pSrvProc, (SRV_DONE_ERROR | SRV_DONE_MORE), 0, 0);}extern "C" __declspec(dllexport) SRVRETCODE WINAPI xp_call_asp_by_onega(SRV_PROC* pSrvProc){ BYTE bType; long cbMaxLen; long cbActualLen; BOOL fNull; // Count up the number of input parameters. //http://community.csdn.net/Expert/TopicView3.asp?id=3960017 //table_name string,record_id int,additional_info string if (srv_rpcparams(pSrvProc) != 3) { printUsage(pSrvProc); return (XP_ERROR); } // Use srv_paraminfo to get data type and length information. int parameter_index = 1; if (srv_paraminfo(pSrvProc, parameter_index, &bType, (ULONG*)&cbMaxLen, (ULONG*)&cbActualLen, NULL, &fNull) == FAIL) { printError (pSrvProc, "srv_paraminfo failed..."); return (XP_ERROR); } // Make sure the parameter is of char or varchar datatype if (bType != SRVBIGVARCHAR && bType != SRVBIGCHAR) { printUsage(pSrvProc); return (XP_ERROR); } char szTable[128]; memset(szTable,0,sizeof(szTable)); memcpy(szTable, srv_paramdata(pSrvProc, parameter_index), srv_paramlen(pSrvProc, parameter_index)); parameter_index = 2; int record_id = 0; memcpy(&record_id, srv_paramdata(pSrvProc, parameter_index), srv_paramlen(pSrvProc, parameter_index)); parameter_index = 3; if (srv_paraminfo(pSrvProc, parameter_index, &bType, (ULONG*)&cbMaxLen, (ULONG*)&cbActualLen, NULL, &fNull) == FAIL) { printError (pSrvProc, "srv_paraminfo failed..."); return (XP_ERROR); } // Make sure the parameter is of char or varchar datatype if (bType != SRVBIGVARCHAR && bType != SRVBIGCHAR) { printUsage(pSrvProc); return (XP_ERROR); } char szAdditionalInfo[128]; memset(szAdditionalInfo,0,sizeof(szAdditionalInfo)); memcpy(szAdditionalInfo, srv_paramdata(pSrvProc, parameter_index), srv_paramlen(pSrvProc, parameter_index)); //check received parameter: std::stringstream ss; ss<<"xp_call_asp_by_onega('"<<szTable<<"',"<<record_id<<",'"<<szAdditionalInfo<<"')"; OutputDebugString(ss.str().c_str()); ss.str(""); ss<<"http://127.0.0.1/xp_call_asp_by_onega.asp?table_name="<<szTable<<"&record_id=" <<record_id<<"&additional_info=" <<szAdditionalInfo; LPCTSTR download_file_name = "c:\\xp_call_asp_by_onega.htm"; DeleteFile(download_file_name); URLDownloadToFile(NULL,ss.str().c_str(),download_file_name,0,NULL); OutputDebugString(ss.str().c_str()); srv_senddone(pSrvProc, (SRV_DONE_COUNT | SRV_DONE_MORE), 0, 1); return (XP_NOERROR);}/*//def fileLIBRARY extended_proc_call_aspEXPORTSxp_call_asp_by_onega__GetXpVersion*//*--install to G:\Program Files\Microsoft SQL Server\80\Tools\Binn\extended_proc_call_asp.dll--sp_addextendedproc 'xp_call_asp_by_onega', 'extended_proc_call_asp.dll'exec xp_call_asp_by_onega 'table2', 2, 'exec xp test'--sp_dropextendedproc 'xp_call_asp_by_onega'*//* xp_call_asp_by_onega.asp<%table_name = request.querystring("table_name")record_id = request.querystring("record_id")additional_info = request.querystring("additional_info")if len(table_name)>0 AND len(additional_info)>0 thenapplication(table_name & cstr(record_id) ) = table_name & "," _& CStr(record_id) & "," & additional_infoend iffor each x in Application.ContentsResponse.Write(x & "=" & Application.Contents(x) & "<br />")next%>*/ listcontrol用不好~~~烦躁 VS2008MFC程序使用CDockablePane作为基类视图的问题~ 关于opengl的glaux库的问题 VC如何使用控件随窗体大小变化 怎么PtInRect(point)) 不起作用? vc全局变量的定义,求拜vc全局变量的各种定义方法,要全面的 如何Enable打印对话框上的“当前页面”radio? MFC中按钮能相互调用吗?怎么调用呀! 哪位仁兄用OLE DB连ACCESS做过东西,有问题想探讨一下 快过来! 在开发SP短信平台时碰到的问题 关于WebBrower控件的问题(内存)
#include "stdafx.h"
#define DBNTWIN32
#include <windows.h>
//G:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Include\sqlfront.h
#include <sqlfront.h>
#include <sqldb.h>
#include <srv.h>
#include <sstream>
#include <UrlMon.h>
#pragma comment(lib,"urlmon.lib")
#define XP_NOERROR 0
#define XP_ERROR 1
#define MAX_BINDTOKEN 256
#define MAX_SERVER_ERROR 20000
#define XP_HELLO_ERROR MAX_SERVER_ERROR+1
//G:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Lib\opends60.lib
//G:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Lib\ntwdblib.lib
#pragma comment(lib,"opends60.lib")
#pragma comment(lib,"Ntwdblib.lib")
//need to download the following dlls
//G:\Program Files\Microsoft SQL Server\80\Tools\Binn\OPENDS60.DLL
//G:\Program Files\Microsoft SQL Server\80\Tools\Binn\ums.DLL
extern "C" __declspec(dllexport) ULONG WINAPI __GetXpVersion()
{
return ODS_VERSION;
}
extern "C" __declspec(dllexport) BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
// send XP usage info to client
void printUsage (SRV_PROC *pSrvProc)
{
// usage: exec xp_call_asp_by_onega <@table_name input> <@record_id input> <@additional_info input>
// Example:
// exec xp_call_asp_by_onega 'table1',1,'for table1'
//build by Onega at 2005/04/23 with VC2003, Windows 2003, SQLServer 2000
srv_sendmsg(pSrvProc, SRV_MSG_ERROR, XP_HELLO_ERROR, SRV_INFO, 1,
NULL, 0, (DBUSMALLINT) __LINE__,
"Usage: exec xp_call_asp_by_onega <@table_name input> <@record_id input> <@additional_info input>",
SRV_NULLTERM);
srv_senddone(pSrvProc, (SRV_DONE_ERROR | SRV_DONE_MORE), 0, 0);
}// send szErrorMsg to client
void printError (SRV_PROC *pSrvProc, CHAR* szErrorMsg)
{
srv_sendmsg(pSrvProc, SRV_MSG_ERROR, XP_HELLO_ERROR, SRV_INFO, 1,
NULL, 0, (DBUSMALLINT) __LINE__,
szErrorMsg,
SRV_NULLTERM); srv_senddone(pSrvProc, (SRV_DONE_ERROR | SRV_DONE_MORE), 0, 0);
}extern "C" __declspec(dllexport) SRVRETCODE WINAPI xp_call_asp_by_onega(SRV_PROC* pSrvProc)
{
BYTE bType;
long cbMaxLen;
long cbActualLen;
BOOL fNull;
// Count up the number of input parameters.
//http://community.csdn.net/Expert/TopicView3.asp?id=3960017
//table_name string,record_id int,additional_info string
if (srv_rpcparams(pSrvProc) != 3)
{
printUsage(pSrvProc);
return (XP_ERROR);
} // Use srv_paraminfo to get data type and length information.
int parameter_index = 1;
if (srv_paraminfo(pSrvProc, parameter_index, &bType, (ULONG*)&cbMaxLen, (ULONG*)&cbActualLen,
NULL, &fNull) == FAIL)
{
printError (pSrvProc, "srv_paraminfo failed...");
return (XP_ERROR);
}
// Make sure the parameter is of char or varchar datatype
if (bType != SRVBIGVARCHAR && bType != SRVBIGCHAR)
{
printUsage(pSrvProc);
return (XP_ERROR);
}
char szTable[128];
memset(szTable,0,sizeof(szTable));
memcpy(szTable, srv_paramdata(pSrvProc, parameter_index), srv_paramlen(pSrvProc, parameter_index));
parameter_index = 2; int record_id = 0;
memcpy(&record_id, srv_paramdata(pSrvProc, parameter_index),
srv_paramlen(pSrvProc, parameter_index));
parameter_index = 3;
if (srv_paraminfo(pSrvProc, parameter_index, &bType, (ULONG*)&cbMaxLen,
(ULONG*)&cbActualLen,
NULL, &fNull) == FAIL)
{
printError (pSrvProc, "srv_paraminfo failed...");
return (XP_ERROR);
}
// Make sure the parameter is of char or varchar datatype
if (bType != SRVBIGVARCHAR && bType != SRVBIGCHAR)
{
printUsage(pSrvProc);
return (XP_ERROR);
} char szAdditionalInfo[128];
memset(szAdditionalInfo,0,sizeof(szAdditionalInfo));
memcpy(szAdditionalInfo, srv_paramdata(pSrvProc, parameter_index),
srv_paramlen(pSrvProc, parameter_index));
//check received parameter:
std::stringstream ss;
ss<<"xp_call_asp_by_onega('"<<szTable<<"',"<<record_id<<",'"<<szAdditionalInfo<<"')";
OutputDebugString(ss.str().c_str());
ss.str("");
ss<<"http://127.0.0.1/xp_call_asp_by_onega.asp?table_name="<<szTable<<"&record_id="
<<record_id<<"&additional_info="
<<szAdditionalInfo;
LPCTSTR download_file_name = "c:\\xp_call_asp_by_onega.htm";
DeleteFile(download_file_name);
URLDownloadToFile(NULL,ss.str().c_str(),download_file_name,0,NULL);
OutputDebugString(ss.str().c_str());
srv_senddone(pSrvProc, (SRV_DONE_COUNT | SRV_DONE_MORE), 0, 1);
return (XP_NOERROR);
}/*
//def file
LIBRARY extended_proc_call_asp
EXPORTS
xp_call_asp_by_onega
__GetXpVersion
*/
/*
--install to G:\Program Files\Microsoft SQL Server\80\Tools\Binn\extended_proc_call_asp.dll
--sp_addextendedproc 'xp_call_asp_by_onega', 'extended_proc_call_asp.dll'
exec xp_call_asp_by_onega 'table2', 2, 'exec xp test'
--sp_dropextendedproc 'xp_call_asp_by_onega'
*/
/* xp_call_asp_by_onega.asp
<%
table_name = request.querystring("table_name")
record_id = request.querystring("record_id")
additional_info = request.querystring("additional_info")
if len(table_name)>0 AND len(additional_info)>0 then
application(table_name & cstr(record_id) ) = table_name & "," _
& CStr(record_id) & "," & additional_info
end if
for each x in Application.Contents
Response.Write(x & "=" & Application.Contents(x) & "<br />")
next%>
*/