用C语言,不用C++的代码啊。

解决方案 »

  1.   

    并非不可能,只是要用到ADO的话,做起来不经济,时间和精力上。如果不用ADO,你可以抓包查询分析器和SQL SERVER数据库服务器之间的TCP协议进行分析一下,用socket和API封装一下,提供自己的API供上层应用调用,但仍然不是很经济
      

  2.   

    我的意思是。
    使用C语言写使用ADO引擎的代码,不是要自己写引擎。
      

  3.   

    ADO 一直到2.8是基于COM的,如果要纯C支持COM,不是不可以,是你自己要写很多实现COM调用的代码。另外一旦使用了COM,遇到BSTR,VARIANT,都需要自己小心封装,而且现有的包装类逃不过C++,尤其是我们通常认为很好用的智能指针包装类,也是基于类的,逃不过C++,纯C直接调用恐怕会有问题,与其你实现C与COM组件通信的所有工作,不如分析查询分析器,这样相对可行一些
      

  4.   

    有个以前的同事曾经自己用C封装过oracle的访问,也是参考分析了oracle客户端来的,不一定实现所有,实现需要的即可当然前提肯定是只能C
      

  5.   

    #import "ado.dll"
    然后就能使用了.生成的文件中有C版本的.
      

  6.   

    如vieri_ch(尘雨-自在飞花轻似梦,无边丝雨细如愁) 所说,纯C调用Com是比较复杂的。用SQLServer API可能比较合适。
      

  7.   

    完全可以mssql 可以直接通过c 函数访问,不通过ado
      

  8.   

    以下例子来自sql server 2000 中的例子,是在Programming with DB-Library for 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);
    }
      

  9.   

    有如下源代码例子可供参考
    C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\DBLib\SQLTestC 
    1. Open the Sqltestc.dsw in Microsoft&reg; Visual C++&reg; 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: 
    &#8226; Include files: C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Include
    &#8226; 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".
      

  10.   

    你可以再开发资料里看到
    dblastrowdbclrbufdbcurrowdbnextrowdbgetrow
    等类似结果集处理的api for c