Public Class frmSelect
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As New DataSet
Dim da As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter("SELECT tblStudInfo.LastName AS myName, tblAddress.Address AS myAddress, tblCourses.CourseName AS myCourse FROM tblStudInfo INNER JOIN tblAddress ON tblStudInfo.AddressID = tblAddress.AddressID INNER JOIN tblCourses ON tblStudInfo.CourseCode = tblCourses.CourseCode WHERE tblStudInfo.StudID = '01-2016-003'", mConnection.myConn)
da.Fill(ds, "tblStudInfo")
Me.TextBox1.Text = ds.Tables("tblStudInfo").Rows(0)("myName").ToString
Me.TextBox2.Text = ds.Tables("tblStudInfo").Rows(0)("myAddress").ToString
Me.TextBox3.Text = ds.Tables("tblStudInfo").Rows(0)("myCourse").ToString
End Sub
End Class
I'm using Visual Basic... I have 3 tables in the Database. I am trying to join 3 tables and pass it to my Dataset named ds. But I got a Syntax Error with the SQL command I have provided. I got no error on joining 2 tables, but when I tried joining 3 tables with the code I have provided above, it is no longer working.