Link to home
Start Free TrialLog in
Avatar of Mayank_Agarwal
Mayank_Agarwal

asked on

SQL Invalid Column name

Hi Guys
Can you find anything wrong with this query, it says invalid column name on all the columns, I am tryinf to display the result in a gridview

Public Sub showPlaceholder()
        Dim pagesGrid As New GridView
        Using myConn As New SqlConnection(connStr)
            Dim sql As String = "SELECT [Pages.pageTitle], [Pages.pageContent], [MenuItems.MenuItemText] from " & _
                                "[Pages], [MenuItems] where [pages.siteID] = [menuitems.siteID] and " & _
                                "[menuitems.siteID] = 3"
            Dim mycommand As New SqlCommand(sql, myConn)
            Dim mydataset As New DataSet
            Dim myadapter As New SqlDataAdapter(mycommand)
            myadapter.Fill(mydataset)
            pagesGrid.DataSource = mydataset
            Dim myPlaceholder As PlaceHolder = Me.UpdatePanel3.FindControl("PlaceHolder1")
            myPlaceholder.Controls.Add(pagesGrid)
        End Using

Open in new window

Avatar of Aneesh
Aneesh
Flag of Canada image

Make sure that the columns pageTitle, pageContent ,siteID exists on "page' table also MenuItemText and SiteID in MenuItems table
Avatar of Mayank_Agarwal
Mayank_Agarwal

ASKER

Yes they all exist, and spelling is corrrect as well.
ASKER CERTIFIED SOLUTION
Avatar of gnoon
gnoon
Flag of Thailand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you should add more brackets
e.g
[Pages.pageTitle] change to [Pages].[pageTitle]

hope this help
Exactly mate, thanks