ADODB pointer
-
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 !!!!!
-
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 !!!!!
-
Perhaps you should be use "_RecordsetPtr* pRs". Try it,then you could be success. Yes,Free Code project~~~~
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
-
Perhaps you should be use "_RecordsetPtr* pRs". Try it,then you could be success. Yes,Free Code project~~~~
-
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