下面代码是显示图片:private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string con=ConfigurationSettings.AppSettings["lib"];
SqlConnection myConnection=new SqlConnection(con); SqlDataAdapter myCommand=new SqlDataAdapter("select imagetit from news where id=(select max(id) from news)",myConnection);  //从数据库中选择id号最大的图片标题名“imagetit”
DataSet news=new DataSet();
myCommand.Fill(news,"imagetit");
string imagename=news.Tables["imagetit"].Rows[0].ToString();
imageSmall.ImageUrl="upload/"+"small/"+imagename;   //显示图片语句,图片保存位置..upload/small/图片 }
是何原因???

解决方案 »

  1.   

    C:\Inetpub\wwwroot\libAdmin\upload\small这是路径
    好象没错
      

  2.   

    看了你的("select imagetit from news where id=(select max(id) from news)",myConnection);
    好象有点问题
      

  3.   

    我觉得id=(select max(id) from news)好象不可以等
    你用 id IN (select max(id) from news)试试,我看了MS-SQL-SERVER数据库的书
    好象没有看到什么ID=(SELECT .....)
    如果在不行,你在upload前面加../试试看
      

  4.   

    to:Toti(as) 
    我在查询分析器里实验过了,这个SQL语句没有错误,既可以用“=”也可以是“in”
      

  5.   

    我想请问你的图片是放在用户控件上的吗?因为在html控件中和web控件中的起始路径是不一样的,html默认情况下是当同一级文件夹,但web会追得更深,直接进根文件夹了!
      

  6.   

    to :yybb520(bbyy) 
    图片保存位置..upload/small/图片
      

  7.   

    试下
    imageSmall.ImageUrl=Server.Mapath("upload/")+"small/"+imagename;
      

  8.   

    你的当前aspx 文件 和 图片的层次关系 贴出来
    还有 你可以 把 "upload/"+"small/"+imagename; 打印出来看一看 是否正确
      

  9.   

    发现问题了:
    SqlDataAdapter myCommand=new SqlDataAdapter("select imagetit from news where id in (select max(id) from news)",myConnection);
    DataSet news=new DataSet();
    myCommand.Fill(news,"imagetit");
    string imagename=news.Tables["imagetit"].Rows[0].ToString();
    imageSmall.ImageUrl="upload/"+"small/"+imagename;
    这个代码的结果是:用浏览器运行后不成功,查看它的源文件
    路径居然是<img id="imageSmall" src="upload/small/System.Data.DataRow" border="0"...
    不是图片名
      

  10.   

    你从表里选出数据,然后选了第0行的数据出来但是你似乎没有选要查看的字段啊老大。。你选出来的是datarow而不是某个具体字段笨