Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I give the codes below plz solve

I want to change the query for ----below code

C#
SqlDataAdapter da_series = new SqlDataAdapter("select top(1) group_title,Image_Name,group_id,group_video_no,Video_id,Video_Name,V_description,convert(varchar, date, 103) as To_Date,left(convert(varchar, date, 103), 2) as up_date, left(convert(varchar, date, 107), 3) as month from UploadVideo where group_title ='" + group_title.Trim() + "' order by group_video_no desc", con);

-----------------------------------------
-----------------------------------------
C#
private void LoadData()
    {

        SqlDataAdapter da = new SqlDataAdapter(" select top(3) group_title,Video_id,Video_name,group_id,Image_Name, Speaker, left(convert(varchar, date, 103), 2) as up_date, left(convert(varchar, date, 107), 3) as month, V_description from UploadVideo where Image_Name<>'' order by Date desc", con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataList1.DataSource = ds.Tables[0];
        DataList1.DataBind();

        DataSet ds_series = new DataSet();
        DataSet ds1 = new DataSet();
        DataSet ds2 = new DataSet();

        SqlDataAdapter da1 = new SqlDataAdapter("select count(distinct(group_id)) from UploadVideo where group_id<>''", con);
        da1.Fill(ds1);




        int group_no = Int32.Parse(ds1.Tables[0].Rows[0][0].ToString());

        SqlDataAdapter da2 = new SqlDataAdapter("select distinct(group_title) from UploadVideo where group_id<>''", con);
        da2.Fill(ds2);
        for (int i = 0; i < group_no; i++)
        {
            string group_title = ds2.Tables[0].Rows[i]["group_title"].ToString();

            SqlDataAdapter da_series = new SqlDataAdapter("select top(1) group_title,Image_Name,group_id,group_video_no,Video_id,Video_Name,V_description,convert(varchar, date, 103) as To_Date,left(convert(varchar, date, 103), 2) as up_date, left(convert(varchar, date, 107), 3) as month from UploadVideo where group_title ='" + group_title.Trim() + "' order by group_video_no desc", con);
            
            da_series.Fill(ds_series);

                DataList8.DataSource = ds_series.Tables[0];
                DataList8.DataBind();
                DataList8.Visible = true;



        }
    }
Posted
Updated 21-Jun-13 0:50am
v3
Comments
Pheonyx 21-Jun-13 6:50am    
So what is your problem? What errors are you getting and on which lines?
Rajesh Anuhya 21-Jun-13 6:53am    
What is the Error?
bhabatosh ojha 21-Jun-13 9:12am    
there is the no error,but i want to display the latest group

1 solution

If you want to display the latest group then remove
where group_title ='" + group_title.Trim() + "' order by group_video_no desc
and replace with
order by [date] desc

I have enclosed date in square brackets [ ] as it is a reserved word in most versions of sql
 
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