Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'TarmyNo'.
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'Crank'.
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'Name'.
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'ORS'
Baiju EP
Member
176 Points
425 Posts
Combine and display in one gridview
Dec 27, 2012 04:23 AM|LINK
in my asp.net web code in vb and sql 2005 database
There are three tables named Staff,Attach,Pdp. i want to display data from these tables in one gridview common field is eff_dt(which is a date field)
field are TrmyNo, Crank,Name,ORS,Eff_dt
sameer_khanj...
Contributor
7066 Points
1381 Posts
Re: Combine and display in one gridview
Dec 27, 2012 04:36 AM|LINK
You can use above query to get records and bind it to grid by using below code :-
private void BindGrid() { using(SqlConnection cn = new SqlConnection("Some Connection string")) using(SqlCommand cmd = new SqlCommand("Select TrmyNo, Crank,Name,ORS, Staff.Eff_dt from Staff inner join Attach on Attach.Eff_dt =Staff.Eff_dt inner join Pdp on Pdp .Eff_dt =Staff.Eff_dt", cn)) { cmd.CommandType = CommandType.Text; cmd.Connection.Open(); using(SqlDataAdapter da = new SqlDataAdapter(cmd)) { DataTable dt = new DataTable(); da.Fill(dt); gridView1.DataSource = dt; gridView1.DataBind(); } } }sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
anurag003iit...
Member
176 Points
111 Posts
Re: Combine and display in one gridview
Dec 27, 2012 06:33 AM|LINK
Hi ,
try to use
1. http://www.aspdotnet-suresh.com/2012/10/how-to-retrieve-data-from-multiple.html for Query
and
http://code.msdn.microsoft.com/VBASPNETGridView-19039173
http://www.softwareexamples.com/ASPNet/Example700/Example700710/Example.aspx
http://tycoontalk.freelancer.com/net-forum/89353-vb-net-populate-a-datagrid-gridview.html for fill ASP.net Gridview uswing vb
Baiju EP
Member
176 Points
425 Posts
Re: Combine and display in one gridview
Dec 27, 2012 01:35 PM|LINK
duplicate names are reflected when running the above query. that was the problem which is faced.
ajaya_rout
Member
156 Points
47 Posts
Re: Combine and display in one gridview
Dec 27, 2012 02:08 PM|LINK
Use Alias to select the query like
If u like to fetch the data in one table with this fields,If the field s are in in Staff table
select s.TrmyNo,s.Crank,s.Name,s.ORS,s.,Eff_dt from Staff s,Attach a, Pdp p where s.eff_dt=a.eff_dt and s.eff_dt=p.eff_dt;
U must use as statement to fill the grid.
like s. TrmyNo as TrmyNo;
fill the datafield value of grid TrmyNo;
Thanks
Baiju EP
Member
176 Points
425 Posts
Re: Combine and display in one gridview
Dec 27, 2012 03:58 PM|LINK
ERROR COMES AS
Incorrect syntax near ','.
sameer_khanj...
Contributor
7066 Points
1381 Posts
Re: Combine and display in one gridview
Dec 27, 2012 04:03 PM|LINK
Select distinct TrmyNo, Crank,Name,ORS, Staff.Eff_dt from Staff inner join Attach on Attach.Eff_dt =Staff.Eff_dt inner join Pdp on Pdp .Eff_dt =Staff.Eff_dt
sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
Baiju EP
Member
176 Points
425 Posts
Re: Combine and display in one gridview
Dec 28, 2012 09:05 AM|LINK
QUERY COMPLETED WITH ERRORS is shown in sql query
The basic requirement is
i want to fetch the data from staff,attach,pdp (tables) whose eff_dt(a date field) is in the dropdownlist
sameer_khanj...
Contributor
7066 Points
1381 Posts
Re: Combine and display in one gridview
Dec 28, 2012 09:13 AM|LINK
Error details ?
sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
Baiju EP
Member
176 Points
425 Posts
Re: Combine and display in one gridview
Dec 28, 2012 09:25 AM|LINK
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'TarmyNo'.
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'Crank'.
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'Name'.
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'ORS'