Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    2

    Unanswered: i want to connect to a ms sql server,but ..."invalid pointer"...why?

    i want to conncet to a ms sql server,but the debug info: "invalid pointer!"
    is there any problems in my coding?
    by debugging, i know the problem must lie in the variant strConnect.
    i use ms sql server 2000+ winxp+ visual c++6.0

    _ConnectionPtr m_pConnection ;
    void ADOConn::OnInitADOConn()
    {
    ::CoInitialize(NULL);
    try
    {
    m_pConnection.CreateInstance("ADODB.Recordset");

    _bstr_t strConnect="Provider=SQLOLEDB;
    TRUSTED_CONNECTION=TRUE;//use windows log in
    Initial Catalog=....../*database name*/;
    Data Source=SJTU-3V87CA6SZP";//server name
    m_pConnection->Open(strConnect,"","",adModeUnknown);


    }
    catch (_com_error e) {
    _bstr_t bstrSource(e.Source());
    _bstr_t bstrDescription(e.Description());
    TRACE( "Exception thrown for classes generated by #import" );
    TRACE( "\tCode = %08lx\n", e.Error());
    TRACE( "\tCode meaning = %s\n", e.ErrorMessage());
    TRACE( "\tSource = %s\n", (LPCTSTR) bstrSource);
    TRACE( "\tDescription = %s\n", (LPCTSTR) bstrDescription);
    }
    }

  2. #2
    Join Date
    Dec 2004
    Posts
    47
    OK, I think you forgot to add the Microsoft.ADODB to the project references list. Try that and let me know.

    Sree

  3. #3
    Join Date
    Dec 2004
    Posts
    2

    do you mean...

    do you mean i must add #import "c:\program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF") rename("BOF","adoBOF")??

    i have added it to the .h file

    if you refer to a different meaning, please tell me the meaning of "project reference list"

    thank you very much!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •