i have the following code that isn't working correct
Dim con As New SqlConnection
Dim cmd As New SqlCommand
Try
con.ConnectionString = "Data Source=" & ServerV & ";Initial Catalog=" & databaseV & ";Persist Security Info=True;User ID=" & usernameV & ";Password=" & passwordV & ""
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT SUM (QtyInvoiced) as Volume FROM ArTrnDetail GROUP BY Customer, TrnYear HAVING(Customer = '1055') AND (TrnYear = 2011)"
Dim lrd As SqlDataReader = cmd.ExecuteReader()
While lrd.Read()
Me.LBprevYearVOL.Text = Convert.ToString(lrd("Volume"))
End While
Catch ex As Exception
MessageBox.Show("Error while retrieving records on table..." & ex.Message, "Load Records")
Finally
con.Close()
End Try
End Sub
please can someone tell me what i am doing wrong. i get a error invalid coloum name SUM