Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two table named cpu and sell and i want to get data in gridview
table cpu has name,image1
table sell has cost,brand
SqlCommand cmd = new SqlCommand("SELECT name,image1,Min(cost),MAX(cost) FROM sell,cpu WHERE", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);     
         DataTable dt = new DataTable();
                GridView1.DataSource = dt;

but this error appear when run
Ambiguous column name 'name'.
Updated 17-Nov-13 8:12am
abbaspirmoradi 17-Nov-13 14:16pm    
are you have column "name" also in your sell table?
m-e-h-d-h-i 17-Nov-13 14:40pm    
m-e-h-d-h-i 17-Nov-13 14:43pm    
I have tried your solution but another error apears...
Column '' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
abbaspirmoradi 17-Nov-13 14:51pm    
ok ,well this is your next problem. check this:"SELECT,image1,Min(cost),MAX(cost) FROM sell,cpu WHERE group by("

1 solution

Try this:

SqlCommand cmd = new SqlCommand("SELECT,image1,Min(cost),MAX(cost) FROM sell,cpu WHERE group by(", con);
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900