Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO and inner join
Message
From
05/10/2000 20:50:12
 
 
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00425620
Message ID:
00425757
Views:
15
>This is holding up my chances of going to the Guerrila VB conference.
>
>How can I do the inner join using ADO. I have the following code that is broken.
>
>
>    Dim s_conn As String
>    Dim cn As ADODB.Connection
>    Dim rs As ADODB.Recordset
>    Set cn = New ADODB.Connection
>    Set rs = New ADODB.Recordset
>    strSQL = "select * from c:\nr_instl.dbf inner join c:\nr_headr.dbf on nr_headr.HD_ID_NUM = nr_instl.IN_ID_NUM where IN_AMOUNT = 0"
>    s_conn = "Driver=Microsoft Visual Foxpro Driver;UID=;SourceType=DBF;Deleted=YES;Null=NO;SourceDB=" <-- What goes here     cn.Open s_conn
>    rs.Open strSQL, cn
>
The problem was that there was not a connection to EACH of the tables. The following code works great: Apparently ADO doesn't like to 'fudge' the second connection even though its a single SQL it still demands an active connection to all parties involved. An interesting point is that the open can use 1 connection ...
    Dim s_conn As String, s_conn1 As String
    
    Dim cn As ADODB.Connection
    Dim cn1 As ADODB.Connection
    
    Dim rs As ADODB.Recordset
    
    Set cn = New ADODB.Connection
    Set cn1 = New ADODB.Connection
    Set rs = New ADODB.Recordset


    s_conn = "Driver=Microsoft Visual Foxpro Driver;UID=;SourceType=DBF;Deleted=YES;Null=NO;SourceDB=c:\nr_instl.dbf"
    s_conn1 = "Driver=Microsoft Visual Foxpro Driver;UID=;SourceType=DBF;Deleted=YES;Null=NO;SourceDB=c:\nr_headr.dbf"
    cn.Open s_conn
    cn1.Open s_conn1
    
    strSQL = "select * from c:\nr_instl.dbf inner join c:\nr_headr.dbf on nr_headr.HD_ID_NUM = nr_instl.IN_ID_NUM where IN_AMOUNT = 0"

    rs.Open strSQL, cn
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform