这是的HTML代码:
<asp:DataList ID="DataList1" runat="server" Width ="100%" Height="183px" >
<ItemTemplate>
<table style ="width :100%" align ="center" >
<tr>
<td width ="65%">
<a href='<%# DataBinder.Eval(Container.DataItem,"path") %>'>
<%# DataBinder.Eval(Container.DataItem,"filename") %>..
</td>
<td width="10%">
<img src="image/new.gif" /></td>
<td width ="25%">
<%# DataBinder.Eval(Container.DataItem,"filetime") %>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
为什么在XP的系统下做服务器测试的时候都能打开连接,但是转到2000当服务器的时候有的连接就打不开了.按理说要是不能打开的话都不能打开啊,打不开的文件在地址拦显示的地址又是正确的,我在服务器的文件夹也看了,也存在哪个文件,地址也对,为什么打不开呢?郁闷中......
<asp:DataList ID="DataList1" runat="server" Width ="100%" Height="183px" >
<ItemTemplate>
<table style ="width :100%" align ="center" >
<tr>
<td width ="65%">
<a href='<%# DataBinder.Eval(Container.DataItem,"path") %>'>
<%# DataBinder.Eval(Container.DataItem,"filename") %>..
</td>
<td width="10%">
<img src="image/new.gif" /></td>
<td width ="25%">
<%# DataBinder.Eval(Container.DataItem,"filetime") %>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
为什么在XP的系统下做服务器测试的时候都能打开连接,但是转到2000当服务器的时候有的连接就打不开了.按理说要是不能打开的话都不能打开啊,打不开的文件在地址拦显示的地址又是正确的,我在服务器的文件夹也看了,也存在哪个文件,地址也对,为什么打不开呢?郁闷中......
DataList1.DataSource = bc.getdataset("select top 5 left(filename,15) as filename,left(filetime,11) as filetime,path from study_file order by filetime desc", "file");
DataList1.DataBind();
上传的:
string str = this.File1.PostedFile.FileName;
string ss = str.Substring(str.LastIndexOf("\\") + 1);
string ss1 = ss.Substring(0, ss.LastIndexOf("."));
string s = Server.MapPath("file\\" + ss);
if (File.Exists(s) == true)
{
File.Delete(s);
}
path = "file\\" + ss;
i = bc.addfile_int(ss1, Convert.ToString(Session["LoginName"]), path , DateTime.Today);
this.File1.PostedFile.SaveAs(s);
if (i > 0)
{
Response.Write(bc.messagebox("发送完毕"));
}
else
{
Response.Write(bc.messagebox("发送失败"));
}
public int addfile_int(string filename, string filesender, string department,string path,DateTime filetime)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["constr"]);
SqlCommand cmd = new SqlCommand("addfilr", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter pfilename = new SqlParameter("@filename", SqlDbType.VarChar, 50);
pfilename.Value = filename;
cmd.Parameters.Add(pfilename);
SqlParameter pfilesender = new SqlParameter("@filesender", SqlDbType.VarChar, 50);
pfilesender.Value = filesender;
cmd.Parameters.Add(pfilesender);
SqlParameter ppath = new SqlParameter("@path", SqlDbType.VarChar, 100);
ppath.Value = path;
cmd.Parameters.Add(ppath);
SqlParameter pfiletime = new SqlParameter("@filetime", SqlDbType.DateTime, 8);
pfiletime.Value = filetime;
cmd.Parameters.Add(pfiletime);
SqlParameter pfileid = new SqlParameter("@fileid", SqlDbType.Int, 4);
pfileid.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(pfileid);
try
{
con.Open();
}
catch (System.Exception e)
{
throw new System.Exception("数据库连接失败", e);
}
try
{
cmd.ExecuteNonQuery();
}
catch (System.Exception ex)
{
throw new System.Exception(ex.Message, ex);
}
con.Close();
return (int)pfileid.Value;
}
这些代码都没有问题的,都能上传到数据库中,也能在datalist上显示出来,但是有的文件就是打不开,连接地址是正确的!