sql - SqlException and I'm not able to resolve it -
i'm facing problem when tried execute query. i'm getting error:
cannot find either column "m" or user-defined function or aggregate "m.gender", or name ambiguous
code:
myconnection.open() dim myreader sqldatareader = mycommand.executereader() /* problem here */ return myreader the query runs fine when execute directly in sql server. problem when executed on button click event in application. (vb.net)
pls, check whole query
select pt.color color, m.model model, m.gender gender, sum(case when month(o.data_ins) = 1 1 else 0 end) jan, sum(case when month(o.data_ins) = 2 1 else 0 end) feb, sum(case when month(o.data_ins) = 3 1 else 0 end) mar, sum(case when month(o.data_ins) = 4 1 else 0 end) apr, sum(case when month(o.data_ins) = 5 1 else 0 end) may, sum(case when month(o.data_ins) = 6 1 else 0 end) jun, sum(case when month(o.data_ins) = 7 1 else 0 end) jul, sum(case when month(o.data_ins) = 8 1 else 0 end) ago, sum(case when month(o.data_ins) = 9 1 else 0 end) sep, sum(case when month(o.data_ins) = 10 1 else 0 end) oct, sum(case when month(o.data_ins) = 11 1 else 0 end) nov, sum(case when month(o.data_ins) = 12 1 else 0 end) dec models m inner join product_type pt on m.model_id = pt.model_id inner join product_orders po on pt.producttype_id = po.producttype_id inner join orders o on po.order_id = o.order_id year(o.date_ins) = 2013 , pt.available = 1 , p.status = 'shipped' group pt.color, m.model, m.gender order pt.color, m.model, m.gender >
public shared function executareader(byval strsql) dim strconn string strconn = configurationsettings.appsettings("strconn") dim myconnection new sqlconnection(strconn) dim mycommand new sqlcommand(strsql, myconnection) myconnection.open() dim myreader sqldatareader = mycommand.executereader() return myreader end function
i think returning table , table models have same column name gender
try m.model model2, m.gender gender2,
Comments
Post a Comment