我在用VC开发数据库时,数据库用的sql server,在控制面板中用odbc 连接时,却总是出现测试失败了,出现如下信息:
运行连接测试...试图连接
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]未找到指定的 SQL Server。测试失败!
我作了两天,却总是这样,查了一些资料,可还是解决不了。我想这是说没连上我的sql server 2000吧。
那么,我想问下各位:这到底是什么问题?如何进行odbc和sql server里的全面配置?有没有解决这些问题的专网站和专业书籍?
  多谢了

解决方案 »

  1.   

    运行E:\WINNT\system32\cliconfg.exe,就是SQL里的客户端网络实用工具,在别名页编辑所用数据库,网络库选用TCP/IP就可以了。
      

  2.   

    你的问题我也遇过,在控制面板的ODBC32数据源的第一步连接中,在”你想连接那个SQL Server的服务器中的名字要同你装SQL时的名字一样,或写(local),第二步中那个ID要“SA”,再填好正确的密码就可以了。
    注意:你必须要启动SQL,在左下角的图标。
    可能讲得不明白,若不行的讲一声,让我再装一遍SQL2000(现在未装)再详细说。
      

  3.   

    两位的方案我在上次提交问题的时候其实已经试过,在有关的几个地方我是按你们说的那样作的,这次我再作了几次,结果还是不行,和我的贴子上的问题一样,我的sql server是处于运行态的(绿色),顺便提一下,我在上一次(传贴之前)安装sql server时,在系统的DSN中(用户DSN中不行)是可以成功进行数据测试,重装之后,我作了一个比较大的数据库,我不想重作它。你们再帮忙仔细看看。多谢了。
      

  4.   

    你是在另一台机器还是sql server本身的机器
      

  5.   

    请问你的操作系统是什么?若是WinME/9x,2000专业版以下的要装个人版,标准版以上的要Win2000 server的。
    最后一个问题是:你的是单机环境吗?
      

  6.   

    谢谢各位对此问题的关心,对你们问题我作以回答:
     我用的是windos 2000 advanced server 版,我用的是单机环境,也就是说,用的是sql server 本身的机器。
      还有,那个地方有此问题的专门讨论区,以及专门的书,请给推荐。
      

  7.   

    去数据库开发->MS-SQL SERVER版问看看吧.
      

  8.   

    How to allocate handles and connect to SQL Server (ODBC)
    To allocate handles and connect to SQL Server Include the ODBC header files Sql.h, Sqlext.h, Sqltypes.h.
    Include the Microsoft® SQL Server™ 2000 driver-specific header file, Odbcss.h.
    Call SQLAllocHandle with a HandleType of SQL_HANDLE_ENV to initialize ODBC and allocate an environment handle.
    Call SQLSetEnvAttr with Attribute set to SQL_ATTR_ODBC_VERSION and ValuePtr set to SQL_OV_ODBC3 to indicate the application will use ODBC 3.x-format function calls.
    Optionally, call SQLSetEnvAttr to set other environment options or SQLGetEnvAttr to get environment options.
    Call SQLAllocHandle with a HandleType of SQL_HANDLE_DBC to allocate a connection handle.
    Optionally, call SQLSetConnectAttr to set connection options or SQLGetConnectAttr to get connection options.
    Call SQLConnect to use an existing data source to connect to SQL Server. 
    OrCall SQLDriverConnect to use a connection string to connect to SQL Server. A minimum complete SQL Server connection string has one of two forms:DSN=dsn_name;UID=login_id;PWD=password;DRIVER={SQL Server};SERVER=server;UID=login_id;PWD=password;If the connection string is not complete, SQLDriverConnect can prompt for the required information. This is controlled by the value specified for the DriverCompletion parameter.OrCall SQLBrowseConnect multiple times in an iterative fashion to build the connection string and connect to SQL Server.Optionally, call SQLGetInfo to get driver attributes and behavior for the SQL Server data source.
    Allocate and use statements. 
    Call SQLDisconnect to disconnect from SQL Server and make the connection handle available for a new connection.
    Call SQLFreeHandle with a HandleType of SQL_HANDLE_DBC to free the connection handle.
    Call SQLFreeHandle with a HandleType of SQL_HANDLE_ENV to free the environment handle. 
    Examples
    A. Allocate handles, then connect by using SQLConnect
    This example shows allocating an environment handle and a connection handle, then connecting by using SQLConnect. It has been simplified by removing much of the error checking.#include <stdio.h>
    #include <string.h>
    #include <windows.h>
    #include <sql.h>
    #include <sqlext.h>
    #include <sqltypes.h>
    #include <odbcss.h>SQLHENV      henv = SQL_NULL_HENV;
    SQLHDBC      hdbc1 = SQL_NULL_HDBC;
    SQLHSTMT      hstmt1 = SQL_NULL_HSTMT;int main() {
       RETCODE retcode;
       UCHAR   szDSN[SQL_MAX_DSN_LENGTH+1] = "MyDSN",
             szUID[MAXNAME] = "sa",
             szAuthStr[MAXNAME] = "MyPassword";    // Allocate the ODBC Environment and save handle.
       retcode = SQLAllocHandle (SQL_HANDLE_ENV, NULL, &henv);   // Notify ODBC that this is an ODBC 3.0 application.
       retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
                         (SQLPOINTER)SQL_OV_ODBC3,
                         SQL_IS_INTEGER);   // Allocate an ODBC connection handle and connect.
       retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc1);
       retcode = SQLConnect(hdbc1, szDSN, (SWORD)strlen(szDSN),
                      szUID, (SWORD)strlen(szUID),
                      szAuthStr, (SWORD)strlen(szAuthStr));
       if ( (retcode != SQL_SUCCESS) && 
          (retcode != SQL_SUCCESS_WITH_INFO) ) {
             // Connect failed, call SQLGetDiagRec for errors.
       }
       else {
          // Connects to SQL Server always return
          // informational messages.  These messages can be
          // retrieved by calling SQLGetDiagRec.
       }   // Allocate statement handles and do ODBC processing.   /* Clean up. */
       SQLDisconnect(hdbc1);
       SQLFreeHandle(SQL_HANDLE_DBC, hdbc1);
       SQLFreeHandle(SQL_HANDLE_ENV, henv);
       return(0);
    }B. Connect to SQL Server without an existing ODBC data source
    This example shows a call to SQLDriverConnect to connect to an instance of SQL Server without requiring an existing ODBC data source:#define MAXBUFLEN   255SQLHENV      henv = SQL_NULL_HENV;
    SQLHDBC      hdbc1 = SQL_NULL_HDBC;
    SQLHSTMT      hstmt1 = SQL_NULL_HSTMT;SQLCHAR      ConnStrIn[MAXBUFLEN] =
             "DRIVER={SQL Server};SERVER=MyServer;"
             "UID=sa;PWD=MyPassWord;DATABASE=pubs;";SQLCHAR      ConnStrOut[MAXBUFLEN];
    SQLSMALLINT   cbConnStrOut = 0;// Make connection without data source. Ask that driver not
    // prompt if insufficient information. Driver returns
    // SQL_ERROR and application prompts user
    // for missing information. Window handle not needed for
    // SQL_DRIVER_NOPROMPT.
    retcode = SQLDriverConnect(hdbc1,      // Connection handle
                      NULL,         // Window handle
                      ConnStrIn,      // Input connect string
                      SQL_NTS,         // Null-terminated string
                      ConnStrOut,      // Address of output buffer
                      MAXBUFLEN,      // Size of output buffer
                      &cbConnStrOut,   // Address of output length
                      SQL_DRIVER_NOPROMPT);
      

  9.   

    这个问题我已经解决,问题在服务器上,应该和运行的那个是完全一样的,同名还不行。不过我要谢谢各位。
       我再提供下面的一些问题,只要是回答了我都给分:
     1、在VC里如何用OPENGL,open GL的主要功用及详细情况。
     2、直接与VC高手交流的地方