Inline Code Example Here
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT MONTH(SalesDate) as MonthlySales,Detail.ProductID, Sum (Detail.Qty/30) as Qty FROM Detail INNER JOIN HeadON Detail.HeadID = Head.HeadIDGroup By MONTH(SalesDate), Detail.ProductID"
Dim da As New SqlDataAdapter("SELECT MONTH(SalesDate) as MonthlySales,Detail.ProductID, Sum (Detail.Qty/30) as Qty FROM Detail INNER JOIN HeadON Detail.HeadID = Head.HeadIDGroup By MONTH(SalesDate), Detail.ProductID", con)
Dim dt As New DataTable
da.Fill(dt)
DataGridView1.DataSource = dt

The above is my query for my datagrid view nd it keeps saying

Incorrect syntax near '.'.

but when i do it in the query bulider in sql server it is fine can someone help please

If this is copied verbatim from your code editor, then you could use some well-placed spaces, especially in and around your join clauses. Maybe in your query builder, they showed as line breaks, but didn't translate well into your code?