欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

c++写的cgi怎么实现内部跳转?如何连接postgresql数据库

更新时间: 2014-01-05 02:04:00 责任编辑: Author_N1

 

C++写的CGI如何实现内部跳转?怎么连接postgreSQL数据库?
C++写的CGI部署在阿帕奇服务器。处理表单只能用数字节拆分的方法么?怎么在CGI中实现内部跳转到某个页面呢?另外C++怎么连接postgreSQL数据库啊?大哥们。求救啊

--参考方法--
就是改http头,类似你这句的功能cgiHeaderContentType("text/html");

要按我说的,在<body>中间输出
<meta http-equiv="Refresh" content="0;URL=./cgi-bin/cgictest.cgi">











/* 获取与数据库的连接 */
static int MiMSSqlConnectSQLServer(MsSqlConnectSt *pConnectSt, SQLHENV &henv, SQLHDBC &hdbc)
{
SQLRETURN hRecode;
char szConnOption[1024];
SQLCHAR szConnStrOut[1024]; 
SQLSMALLINT cbConnStrOut = 0;
int nRet = WAVETOP_BACKUP_OK;

/* Allocate environment handle */
hRecode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); 
if (hRecode != SQL_SUCCESS && hRecode != SQL_SUCCESS_WITH_INFO) {
nRet = WAVETOP_BACKUP_INVALID_SYNTAX;
goto CLEANUP;
}

/* Set the ODBC version environment attribute */
hRecode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); 
if (hRecode != SQL_SUCCESS &&
hRecode != SQL_SUCCESS_WITH_INFO) {
nRet = WAVETOP_BACKUP_INVALID_SYNTAX;
goto CLEANUP;
}

/* Allocate connection handle */
hRecode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); 
if (hRecode != SQL_SUCCESS && hRecode != SQL_SUCCESS_WITH_INFO) {
nRet = WAVETOP_BACKUP_INVALID_SYNTAX;
goto CLEANUP;
}

/* Set login timeout to 10 seconds. */
SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (void*)10, 0);

/* connect string */
if (stricmp(pConnectSt->szInstance, "MSSQLServer") == 0) {
_snprintf(szConnOption, sizeof(szConnOption), "DRIVER={SQL Server};"
"server=%s;uid=%s;pwd=%s",
pConnectSt->szHostIP, pConnectSt->szDBUser, pConnectSt->szPassword);
}
else {
_snprintf(szConnOption, sizeof(szConnOption), "DRIVER={SQL Server};"
"server=%s\\%s;uid=%s;pwd=%s",
pConnectSt->szHostIP, pConnectSt->szInstance,
pConnectSt->szDBUser, pConnectSt->szPassword);
}

/* Connect to data source */
hRecode = SQLDriverConnect(hdbc,
NULL,
(unsigned char *)szConnOption,
SQL_NTS,
szConnStrOut,
sizeof(szConnStrOut),
&cbConnStrOut,
SQL_DRIVER_NOPROMPT);

if (hRecode != SQL_SUCCESS && hRecode != SQL_SUCCESS_WITH_INFO) {
nRet = WAVETOP_BACKUP_INVALID_SYNTAX;
goto CLEANUP;


return nRet;

CLEANUP:
MiMSSqlClear(henv, hdbc);
return nRet;
}
//大概这样一个过程,最近写的代码,LZ自己看看












------------------------------------------------------------
http://www.jiemengwu.com/ 解梦屋 http://www.phpzy.com/php/ 绿色php资源http://www.shopfw.com网店服务
上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 02:04:00
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/5241/
本文WWW.DOC100.NET DOC100.NET版权所有。