• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Using VB6, how do i refernece a sql query with three tables

Hi,
    I have an sql statement which selects all the information in 3 tables and then takes it in to VB as an object “objRS” see below :-
    Set objConn = New ADODB.Connection
    Set objRS = New ADODB.Recordset
    Dim objErr As ADODB.Error
    Dim check As Boolean
    Dim Check1 As Boolean
                       
    objConn.Open "Driver=SQL Server; Server=BOSS;" & _
                "Database=Project"
               
    If objConn.State = adStateOpen Then
      'Open a recordset
                       
        objRS.Open "SELECT * FROM Vet, Management, Assistant ", objConn, adOpenForwardOnly, _
                       adLockReadOnly, adCmdText
       
        Do While Check1 = False
            MsgBox (objRS! M_StaffNo)
            If objRS.EOF Or objRS.BOF Then
                MsgBox "Not Found, Error in Database"
                Check1 = True
                Exit Do
            Else
                If S_no.Text = objRS!V_StaffNo Then
                    Frame_Vet.Visible = True
                    Frame_Comments.Visible = True
                    V_Salery.Text = objRS!V_Salery
                    V_Room.Text = objRS!V_Room
                    V_status.Text = objRS!V_status
                    Comment.Text = objRS!V_comments
                    Check1 = True
                End If

The problem here is:- how do I reference information from each table in the query. Is it  objRS!Vet.V_StaffNo or how do I tell the different between the data.

Thanks
Glenelly22
0
glenelly22
Asked:
glenelly22
  • 4
  • 2
1 Solution
 
SethiCommented:
Simply use the name of the field of the table in the recordset object like this:
objRs("V_comments")
0
 
SethiCommented:
Also ensure to attach an empty string while assigning any recordset value to a textbox else you might get an error if the value is Null. Example:
 V_Salery.Text = objRS("V_Salery") & ""
0
 
glenelly22Author Commented:
Sethi
 Could I ask you another question?
Do you know how i could create a samll Calendar for my system.

Thanks
Glenelly22
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SethiCommented:
There is Microsoft calender Control in VB that can be used. Go to Components>Microsoft Calender Control.
0
 
glenelly22Author Commented:
Thanks Sethi..
0
 
SethiCommented:
Anytime buddy.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now