用C语言,不用C++的代码啊。
解决方案 »
- 为什么CreateWindow创建AtlAxWin是为什么会打开网页啊?
- 如何用mfc实现对视频中是否出现全黑画面的判断
- WTL里用向导生成View是Html的框架时,CAxWindow是怎么知道是创建WebBrowser的?
- 如何将两个SOCKET连接起来
- CFile读取二进制文件的问题
- 在线急等,编译出错,这是为什么?帮忙看一下吧,小女子先谢了
- 怎样改变自定对话框中的Static Text文本的内容?
- 如何使用消息实现鼠标点击功能?
- 发布ActiveX控件疑惑的三个问题。
- 请教高手:SDK编程中,如何读取文件中一行数据(以\0结尾)
- 命令行启动应用程序
- 如何得到"c:\aa\bb.exe"的路径"c:\aa\"(注:用C++取得)
使用C语言写使用ADO引擎的代码,不是要自己写引擎。
然后就能使用了.生成的文件中有C版本的.
使用的C,但依然是windows平台下的开发例子,使用for c的api,不是ADO。
#define DBNTWIN32
#include <stdio.h>
#include <windows.h>
#include <sqlfront.h>
#include <sqldb.h>// Forward declarations of the error handler and message handler.
int err_handler(PDBPROCESS, INT, INT, INT, LPCSTR, LPCSTR);
int msg_handler(PDBPROCESS, DBINT, INT, INT, LPCSTR, LPCSTR,
LPCSTR, DBUSMALLINT);main()
{
PDBPROCESS dbproc; // The connection with SQL Server.
PLOGINREC login; // The login information.
DBCHAR name[100];
DBCHAR city[100]; // Install user-supplied error- and message-handling functions.
dberrhandle (err_handler);
dbmsghandle (msg_handler); // Initialize DB-Library.
dbinit (); // Get a LOGINREC.
login = dblogin ();
DBSETLUSER (login, "my_login");
DBSETLPWD (login, "my_password");
DBSETLAPP (login, "example"); // Get a DBPROCESS structure for communication with SQL Server.
dbproc = dbopen (login, "my_server"); // Retrieve some columns from the authors table in the
// pubs database. // First, put the command into the command buffer.
dbcmd (dbproc, "SELECT au_lname, city FROM pubs..authors");
dbcmd (dbproc, " WHERE state = 'CA' "); // Send the command to SQL Server and start execution.
dbsqlexec (dbproc); // Process the results.
if (dbresults (dbproc) == SUCCEED)
{
// Bind column to program variables.
dbbind (dbproc, 1, NTBSTRINGBIND, 0, name);
dbbind (dbproc, 2, NTBSTRINGBIND, 0, city); // Retrieve and print the result rows.
while (dbnextrow (dbproc) != NO_MORE_ROWS)
{
printf ("%s from %s\n", name, city);
}
} // Close the connection to SQL Server.
dbexit (); return (0);
}int err_handler (PDBPROCESS dbproc, INT severity,
INT dberr, INT oserr, LPCSTR dberrstr, LPCSTR oserrstr)
{
printf ("DB-Library Error %i: %s\n", dberr, dberrstr);
if (oserr != DBNOERR)
{
printf ("Operating System Error %i: %s\n", oserr, oserrstr);
}
return (INT_CANCEL);
}int msg_handler (PDBPROCESS dbproc, DBINT msgno, INT msgstate,
INT severity, LPCSTR msgtext, LPCSTR server,
LPCSTR procedure, DBUSMALLINT line)
{
printf ("SQL Server Message %ld: %s\n", msgno, msgtext);
return (0);
}
C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\DBLib\SQLTestC
1. Open the Sqltestc.dsw in Microsoft® Visual C++® 6.0.
2. From the Tools menu, choose Options, and then click the Directories tab.
3. From the Show directories for box, choose Include files and Library files, and ensure that the following directories (as appropriate) are included:
• Include files: C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Include
• Library files: C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Lib
4. Ensure that the hard-coded server name, user name, and password are correct.
5. Compile the program.
6. Open a Command Prompt window, and then change the current directory to C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\DBLib\Sqltestc.
7. Run the program by entering "sqltestc". Open a Command Prompt window, and then change the current directory to C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\DBLib\Sqltestc. Run the program by entering "sqltestc".
dblastrowdbclrbufdbcurrowdbnextrowdbgetrow
等类似结果集处理的api for c