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
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
Make sure that the columns pageTitle, pageContent ,siteID exists on "page' table also MenuItemText and SiteID in MenuItems table
ASKER
Yes they all exist, and spelling is corrrect as well.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you should add more brackets
e.g
[Pages.pageTitle] change to [Pages].[pageTitle]
hope this help
e.g
[Pages.pageTitle] change to [Pages].[pageTitle]
hope this help
ASKER
Exactly mate, thanks