开发者

Image rating aplication problems in C#

I have a problem with the picture rating application that I am working on. I don’t regularly program with C#, so if anyone could help, that would be the best thing that has happened so far to me!!

I am programming in visual studio 2008, the base for the application is made in Microsoft Access.

So what I am trying to do:

I have made a table in Access and I am tr开发者_运维知识库ying to get some information out of it. The table name is dogodek and it consists of id_dogodek, id_category, title, author, ratings and picture (just URL-s). So I can fill the table in my application, but I have a problem, how to present the picture with the highest rating. I don’t know how to load the information’s from the base and then use it.

This is what I have done!

private void images()
{
    OleDbConnection conn = new OleDbConnection(WebConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);
    conn.Open();

    string sql = "SELECT id_dogodek,picture,MAX(ratings) FROM 'dogodek'"; //it do not work


    OleDbDataAdapter da = new OleDbDataAdapter(sql,conn);
    DataSet ds = new DataSet();
    da.Fill(ds);
    //How to load the image to (Image1)??
    Image1.ImageUrl = "images/" + ds.Tables[0].Rows[0]["fotografija"].ToString();

    conn.Close();
}

Please help!!


SELECT TOP 1 id_dogodek,picture,ratings
FROM 'dogodek'
ORDER BY ratings DESC

MAX(ratings) is only for when you're grouping (GROUP BY), ie if there's another table that has lots of ratings for each id_dogodek.


This should work

SELECT *
FROM
(
   SELECT ROW_NUMBER() over (ORDER BY ratings DESC) AS 'Order' , id_dogodek,picture,ratings
   FROM dogodek
) D
WHERE [Order] =1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜