Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15919

VB.NET (UNION) sql query

$
0
0
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:

Viewing all articles
Browse latest Browse all 15919

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>