J
Jonathan Wood
I'm writing a Website that contains the following code:
// Query article data
SqlDataAdapter adap = new SqlDataAdapter("Select art_name, art_date,
art_desc, auth_name," +
" '" + ResolveUrl("~/") + "Articles/' + grp_folder + '/' + cat_folder + '/'
+ art_filename + '.aspx' AS art_path" +
" FROM Articles, Authors, Categories, Groups" +
" WHERE cat_id = '" + id.ToString() + "' AND art_auth_id = auth_id AND
art_cat_id = cat_id AND cat_grp_id = grp_id" +
" ORDER BY art_name", conn);
DataSet ds = new DataSet();
adap.Fill(ds);
// Assign datasource to grid
GridView1.DataSource = ds;
GridView1.DataBind();
It's working correctly but I'm new to this and have a couple of questions.
1. Does my SQL statement seem reasonably efficient and correctly formed? Or
am I asking for performance problems with a page that renders with complex
queries?
2. How can I find out if no rows were returned?
Thanks!
// Query article data
SqlDataAdapter adap = new SqlDataAdapter("Select art_name, art_date,
art_desc, auth_name," +
" '" + ResolveUrl("~/") + "Articles/' + grp_folder + '/' + cat_folder + '/'
+ art_filename + '.aspx' AS art_path" +
" FROM Articles, Authors, Categories, Groups" +
" WHERE cat_id = '" + id.ToString() + "' AND art_auth_id = auth_id AND
art_cat_id = cat_id AND cat_grp_id = grp_id" +
" ORDER BY art_name", conn);
DataSet ds = new DataSet();
adap.Fill(ds);
// Assign datasource to grid
GridView1.DataSource = ds;
GridView1.DataBind();
It's working correctly but I'm new to this and have a couple of questions.
1. Does my SQL statement seem reasonably efficient and correctly formed? Or
am I asking for performance problems with a page that renders with complex
queries?
2. How can I find out if no rows were returned?
Thanks!