怎么记录用户下载成功呢?
ysx_5 2004-07-20 02:27:06 以下是我的代码,但用户点了取消,数据库还是有记录
请指点
谢谢
------
strFileName = dgFilesList.Items[dgFilesList.SelectedIndex].Cells[2].Text.ToString();
string strUrlString = "\\Files\\" + strFileName;
string strFileMapPath = Server.MapPath("./") + strUrlString;
string strSQL ="insert into download (file_id,user_id,download_datetime,download_ip,download_hostname) values ('";
strSQL += dgFilesList.Items[dgFilesList.SelectedIndex].Cells[0].Text.ToString() + "','";
strSQL += strUserID + "',#";
strSQL += DateTime.Now.ToString() + "#,'";
strSQL += strIPAdress + "','";
strSQL += strHostName + "')";
if(!System.IO.File.Exists(strFileMapPath)) //服务器上没有这个文件
{
lbMessage.Text = "提示:出错!未能在服务器文档中寻找到该文件。";
return;
}
else
{
cm = new OleDbCommand(strSQL ,cn);
cn.Open();
cm.ExecuteNonQuery();
cn.Close();
}
Page.Response.Clear();
Page.Response.AddHeader("Content-Type", "text/htm");
Page.Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(strFileMapPath));
Page.Response.WriteFile(strFileMapPath);
Page.Response.End();