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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ADODB pointer

ADODB pointer

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasesysadminhelpquestion
5 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.
  • _ Offline
    _ Offline
    _crs_
    wrote on last edited by
    #1

    hello, I want to send a pointer from my VB client app. to a VC dll the code is : for VB ------- Private Declare Sub GenerateReport Lib "Generator.dll" (ByVal datele As ADODB.Recordset) Private Sub Command1_Click() Dim con As ADODB.Connection Dim rs As ADODB.Recordset c = "PROVIDER=sqloledb;server=romulus;uid=sa;pwd=951;DataBase=SindServLast" Set con = New ADODB.Connection con.Open c Dim s As String s = "select * from T_USR_Useri" Set rs = con.Execute(s) GenerateReport rs End Sub fot VC dll ----------- void GenerateReport(_RecordsetPtr pRs) { pRs->MoveFirst(); CString text; text=(char*)((_bstr_t)pRs->Fields->GetItem((_variant_t)("usr_LoginName"))->Value); } and everything works fine in vc ... the pointer is recived correctly and the text CString is filled ok but after that when my c++ function ends and the execution returns to VB the VB client crushes ... and raise an access violation error .. why ? thanks !!!!!

    C 1 Reply Last reply
    0
    • _ _crs_

      hello, I want to send a pointer from my VB client app. to a VC dll the code is : for VB ------- Private Declare Sub GenerateReport Lib "Generator.dll" (ByVal datele As ADODB.Recordset) Private Sub Command1_Click() Dim con As ADODB.Connection Dim rs As ADODB.Recordset c = "PROVIDER=sqloledb;server=romulus;uid=sa;pwd=951;DataBase=SindServLast" Set con = New ADODB.Connection con.Open c Dim s As String s = "select * from T_USR_Useri" Set rs = con.Execute(s) GenerateReport rs End Sub fot VC dll ----------- void GenerateReport(_RecordsetPtr pRs) { pRs->MoveFirst(); CString text; text=(char*)((_bstr_t)pRs->Fields->GetItem((_variant_t)("usr_LoginName"))->Value); } and everything works fine in vc ... the pointer is recived correctly and the text CString is filled ok but after that when my c++ function ends and the execution returns to VB the VB client crushes ... and raise an access violation error .. why ? thanks !!!!!

      C Offline
      C Offline
      Chao Zuo
      wrote on last edited by
      #2

      Perhaps you should be use "_RecordsetPtr* pRs". Try it,then you could be success. Yes,Free Code project~~~~

      T _ 2 Replies Last reply
      0
      • C Chao Zuo

        Perhaps you should be use "_RecordsetPtr* pRs". Try it,then you could be success. Yes,Free Code project~~~~

        T Offline
        T Offline
        Toni78
        wrote on last edited by
        #3

        suncho wrote: Perhaps you should be use "_RecordsetPtr* pRs". I doubt it. _RecordsetPtr is a smart pointer. Nevertheless, he could try it. You have no idea how many times I am wrong. // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie

        C 1 Reply Last reply
        0
        • C Chao Zuo

          Perhaps you should be use "_RecordsetPtr* pRs". Try it,then you could be success. Yes,Free Code project~~~~

          _ Offline
          _ Offline
          _crs_
          wrote on last edited by
          #4

          if I use _RecordsetPtr *pRs it will get me compiler errors ... _RecordsetPtr it is already a pointer ... and his sizeof is 4

          1 Reply Last reply
          0
          • T Toni78

            suncho wrote: Perhaps you should be use "_RecordsetPtr* pRs". I doubt it. _RecordsetPtr is a smart pointer. Nevertheless, he could try it. You have no idea how many times I am wrong. // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie

            C Offline
            C Offline
            Chao Zuo
            wrote on last edited by
            #5

            this is a way, yes, use a pointer's pointer. In fact, i doubt it too, but should be try.:-D Yes,Free Code project~~~~

            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