Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. SQL Server API problem...

SQL Server API problem...

Scheduled Pinned Locked Moved Web Development
c++sysadminhelpworkspacedatabase
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hello; I have trouble with SQL Server 7.0 API. I'm getting following error at link phase. Source code at below; (VC++ 6) // SmcDatabase.cpp: implementation of the CSmcDatabase class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "smc_client.h" #include "SmcDatabase.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif #define MAXBUFLEN 255 #include #include #include #include #include #include #include #include ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CSmcDatabase::CSmcDatabase() { } CSmcDatabase::~CSmcDatabase() { } HRESULT CSmcDatabase::Connect(char* server, char* uid, char* pwd) { SQLHENV henv = SQL_NULL_HENV; SQLHDBC hdbc1 = SQL_NULL_HDBC; RETCODE retcode = 0; // This format of the SAVEFILE keyword saves a successful // connection as the file Myfiledsn.dsn in the ODBC default // directory for file DSNs. SQLCHAR szConnStrIn[MAXBUFLEN] = "SAVEFILE=MyFileDSN;DRIVER={SQL Server};SERVER=MySQL;" "NETWORK=dbmssocn;UID=sa;PWD=MyPassWord;"; SQLCHAR szConnStrOut[MAXBUFLEN]; SQLSMALLINT cbConnStrOut = 0; // Allocate the ODBC Environment and save handle. retcode = SQLAllocHandle (SQL_HANDLE_ENV, NULL, &henv); // Let ODBC know 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 = SQLDriverConnect(hdbc1, // Connection handle NULL, // Window handle szConnStrIn, // Input connect string SQL_NTS, // Null-terminated string szConnStrOut, // Addr of output buffer MAXBUFLEN, // Size of output buffer &cbConnStrOut, // Address of output length SQL_DRIVER_NOPROMPT); return(retcode); } Error message; --------------------Configuration: smc_cl

    R 1 Reply Last reply
    0
    • L Lost User

      Hello; I have trouble with SQL Server 7.0 API. I'm getting following error at link phase. Source code at below; (VC++ 6) // SmcDatabase.cpp: implementation of the CSmcDatabase class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "smc_client.h" #include "SmcDatabase.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif #define MAXBUFLEN 255 #include #include #include #include #include #include #include #include ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CSmcDatabase::CSmcDatabase() { } CSmcDatabase::~CSmcDatabase() { } HRESULT CSmcDatabase::Connect(char* server, char* uid, char* pwd) { SQLHENV henv = SQL_NULL_HENV; SQLHDBC hdbc1 = SQL_NULL_HDBC; RETCODE retcode = 0; // This format of the SAVEFILE keyword saves a successful // connection as the file Myfiledsn.dsn in the ODBC default // directory for file DSNs. SQLCHAR szConnStrIn[MAXBUFLEN] = "SAVEFILE=MyFileDSN;DRIVER={SQL Server};SERVER=MySQL;" "NETWORK=dbmssocn;UID=sa;PWD=MyPassWord;"; SQLCHAR szConnStrOut[MAXBUFLEN]; SQLSMALLINT cbConnStrOut = 0; // Allocate the ODBC Environment and save handle. retcode = SQLAllocHandle (SQL_HANDLE_ENV, NULL, &henv); // Let ODBC know 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 = SQLDriverConnect(hdbc1, // Connection handle NULL, // Window handle szConnStrIn, // Input connect string SQL_NTS, // Null-terminated string szConnStrOut, // Addr of output buffer MAXBUFLEN, // Size of output buffer &cbConnStrOut, // Address of output length SQL_DRIVER_NOPROMPT); return(retcode); } Error message; --------------------Configuration: smc_cl

      R Offline
      R Offline
      Remco V
      wrote on last edited by
      #2

      Sounds you're not linking odbc32.lib. Don't know right now how to add it exactly (in .NET -> project properties, Linker, Input, Additional Dependencies) Succes!

      O 1 Reply Last reply
      0
      • R Remco V

        Sounds you're not linking odbc32.lib. Don't know right now how to add it exactly (in .NET -> project properties, Linker, Input, Additional Dependencies) Succes!

        O Offline
        O Offline
        Orkun GEDiK
        wrote on last edited by
        #3

        Thank you. Ahmet Orkun GEDiK

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups