请问 ODBC 跟 dbopen() 的关系

2ndboy 2003-03-16 08:18:10
看到一个 ODBC 的教程上说要用 SQLAllocHandle() 这一族函数,可是又看到有 dbopen() 这么一族函数,那么 dbopen() 跟 ODBC 有什么关系呢?SQLAllocHandle() 呢?

最好详细一些,我对数据库的概念很弱,谢谢!
...全文
141 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
shiyongfan 2003-03-18
  • 打赏
  • 举报
回复
dbopen是SQLSERVER 的DB-LIBRARY编程接口是的一个函数。
这个编程接口是用来直接和数据库服务器相连的。不通过
ODBC。这个编程接口也不ODBC的专用API。它是SQLSERVER
的API。用它编程很麻烦,比ODBCAPI还要麻烦。

各种数据库都有自己的C接口,MySQL也有。
cool_ice 2003-03-17
  • 打赏
  • 举报
回复
logs in to SQL Server, and initializes any default options.说明它是用于sql server的
cool_ice 2003-03-16
  • 打赏
  • 举报
回复
下面是msdn中的解释:
dbopen
Allocates and initializes a DBPROCESS connection structure.

Syntax
PDBPROCESS dbopen (
PLOGINREC login,
LPCSTR servername );

Arguments
login

Is a pointer to a LOGINREC structure. You can get one by calling dblogin.

servername

Is the name of the server running Microsoft® SQL Server™ 2000 to connect to. This parameter can be the name of an actual SQL Server, NULL or a null string to connect to a local SQL Server, or the logical name matching an entry in the Win.ini file or the Microsoft Windows NT® 4.0 Registry.

Returns
A DBPROCESS pointer if everything is correct. Ordinarily, NULL is returned if a DBPROCESS structure could not be created or initialized, or if your login to SQL Server failed. When NULL is returned, the user-supplied error handler is called to indicate the error.
注释:
The DBPROCESS structure is the basic data structure that DB-Library uses to communicate with SQL Server. The application needs a DBPROCESS structure to communicate with SQL Server. It is the first parameter in almost every DB-Library call. Besides allocating the DBPROCESS structure, this function sets up communication with the network, logs in to SQL Server, and initializes any default options.

用法:
DBPROCESS *dbproc;
LOGINREC *loginrec;

loginrec = dblogin();
DBSETLUSER(loginrec, "user");
DBSETLPWD(loginrec, "my_password");
DBSETLAPP(loginrec, "my_program");
dbproc = dbopen(loginrec, "my_server");

我的理解是dbopen是sqlserver odbc的专用api!

4,018

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧