标题:[求助]SQL数据库丢了看代码可以重新建立吗?
只看楼主
pollyworks
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-5-16
 问题点数:0 回复次数:0 
[求助]SQL数据库丢了看代码可以重新建立吗?

SQL数据库丢了看代码可以重新建立吗?


里面有这些内容


BOOL CSQL::DBConnect(unsigned char * Server,unsigned char * User,unsigned char* Pass)
{
SQLRETURN ret;
ret = SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &g_henv); if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) return FALSE;
ret = SQLSetEnvAttr (g_henv,SQL_ATTR_ODBC_VERSION,(void*)SQL_OV_ODBC3, 0); if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) return FALSE;
ret = SQLAllocHandle (SQL_HANDLE_DBC, g_henv, &g_hdbc); if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) return FALSE;
ret = SQLSetConnectAttr (g_hdbc,SQL_LOGIN_TIMEOUT,(SQLPOINTER)5, 0); if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) return FALSE;
ret = SQLConnect (g_hdbc,Server,SQL_NTS,User,SQL_NTS,Pass,SQL_NTS); if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) return FALSE;
return TRUE;
}
void CSQL::DBRelease()
{
if (g_hdbc) SQLDisconnect(g_hdbc);
if (g_hdbc) SQLFreeHandle(SQL_HANDLE_DBC, g_hdbc);
if (g_henv) SQLFreeHandle(SQL_HANDLE_ENV, g_henv);
if (g_hstmt) SQLFreeHandle(SQL_HANDLE_STMT, g_hstmt);
}

// szQuery = "select map_name map_info map_size init_money, need_money1, need_money2 from maplist order by map_name";
BOOL CSQL::ExecuteStart(char * szQuery)
{
SQLRETURN ret;
ret = SQLAllocHandle(SQL_HANDLE_STMT, g_hdbc, &g_hstmt); if (ret!=SQL_SUCCESS && ret!=SQL_SUCCESS_WITH_INFO) return FALSE;
ret = SQLPrepare(g_hstmt, (SQLCHAR*)szQuery, SQL_NTS); if ( ret!=SQL_SUCCESS && ret!=SQL_SUCCESS_WITH_INFO ) return FALSE;
ret = SQLExecute(g_hstmt); if ( ret!=SQL_SUCCESS && ret!=SQL_SUCCESS_WITH_INFO ) return FALSE;
return TRUE;
}

BOOL CSQL::GetStmt(void)
{ SQLRETURN ret;
ret = SQLAllocHandle(SQL_HANDLE_STMT, g_hdbc, &g_hstmt); if (ret!=SQL_SUCCESS && ret!=SQL_SUCCESS_WITH_INFO) return FALSE;
return TRUE;
}
BOOL CSQL::FreeStmt(void)
{ if (g_hstmt) SQLFreeHandle(SQL_HANDLE_STMT /*|SQL_RESET_PARAMS */, g_hstmt);
g_hstmt=NULL;
return TRUE;
}

BOOL CSQL::ExecuteEnd()
{ SQLFreeHandle(SQL_HANDLE_STMT, g_hstmt);
return TRUE;
}



...........................................

搜索更多相关主题的帖子: SQL 数据库 代码 
2006-08-19 01:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-84827-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050315 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved