ADODB recordset
-
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 in a vb dll ... 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 in a vb dll ... why ? thanks !!!!!
My be due to passing the object by value rather than reference (but no promises!) Try :
GenerateReport **ByRef** rs
"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox