VB.NET (UNION) sql query

  • Thread starter Thread starter kafsar
  • Start date Start date
K

kafsar

Guest
I have the following query, when execute the following error out:

Error: 'A field or property with the name 'sta' was not found on the selected data source.'


Code:
Dim dt As DataTable = New DataTable()

        dt = BindGrid("SELECT departmentname as deptname, MAX(departmenttype) as deptType, COUNT(sta) as sta1 FROM staff " &
                                   "where sta = '1' and companyid = '" & Session("compId") & "' GROUP by departmentname " &
                                   "UNION " &
                                   "Select departmentname as deptname, MAX(departmenttype) as deptType, COUNT(sta) as sta2 FROM stafftemp " &
                                   "where sta = '2' and companyid = '" & Session("compId") & "' GROUP by departmentname")

       
        GridView3.DataSource = dt
        GridView3.DataBind()

Can please someone help:

Continue reading...
 
Back
Top