有两个子页面 功能都差不多 上传下载 就是保存的数据库表不一样 第一个页面没问题 第二个页面我就直接把第一个页面复制过去了 包括CS代码也是复制过去的 文件保存的表改了 但是第二个页面上传的文件怎么还是保存到第一个页面使用的数据库表里面去了呢???该改的地方我都改了啊
CS代码:
public partial class xtadd : System.Web.UI.Page
{
public string fname;
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button3_Click(object sender, EventArgs e)
{
if (UploadFile.Value != null && UploadFile.Value != "")
{
hsgupload();
}
string sql;
sql = "insert into allxiti(title,fn) values('" + mc.Text.ToString().Trim() + "','" + fname + "')";
int result;
result = new Class1().hsgexucute(sql);
if (result == 1)
{
Response.Write("<script>javascript:alert('操作成功');</script>");
}
else
{
Response.Write("<script>javascript:alert('系统错误');</script>");
}
}
private void hsgupload()
{
if (UploadFile.Value != null)
{
string nam = UploadFile.PostedFile.FileName;
int i = nam.LastIndexOf(".");
string newext = nam.Substring(i);
DateTime now = DateTime.Now;
string newname = now.DayOfYear.ToString() + UploadFile.PostedFile.ContentLength.ToString();
UploadFile.PostedFile.SaveAs(Server.MapPath("uppic/" + newname + newext));
fname = newname + newext;
}
}
}
CS代码:
public partial class xtadd : System.Web.UI.Page
{
public string fname;
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button3_Click(object sender, EventArgs e)
{
if (UploadFile.Value != null && UploadFile.Value != "")
{
hsgupload();
}
string sql;
sql = "insert into allxiti(title,fn) values('" + mc.Text.ToString().Trim() + "','" + fname + "')";
int result;
result = new Class1().hsgexucute(sql);
if (result == 1)
{
Response.Write("<script>javascript:alert('操作成功');</script>");
}
else
{
Response.Write("<script>javascript:alert('系统错误');</script>");
}
}
private void hsgupload()
{
if (UploadFile.Value != null)
{
string nam = UploadFile.PostedFile.FileName;
int i = nam.LastIndexOf(".");
string newext = nam.Substring(i);
DateTime now = DateTime.Now;
string newname = now.DayOfYear.ToString() + UploadFile.PostedFile.ContentLength.ToString();
UploadFile.PostedFile.SaveAs(Server.MapPath("uppic/" + newname + newext));
fname = newname + newext;
}
}
}
解决方案 »
- SqlDataAdapter.Update 外加条件
- 每天都出现的问题,
- 要做个统计表请各位给点提示
- .net 先绑定数据再进行更新,为什么更新不了数据啊。请帮忙看下。谢谢
- 控制台程序可以识别英国日期格式"22/09/2005",为什么ASP.NET页面不能?
- System.NullReferenceException: 未将对象引用设置到对象的实例
- 请高手推荐几本书asp.net方面的书,最好入门简单的。谢谢!最好是电子版的。
- textbox有点多,该怎么布局?
- 请教ASP.NET控件(C#)开发的方法
- 关于用ASP.net实现统计在线人数的问题
- 请教大家不同项目语言Session取值问题
- 请问如何在html 中 用正则表达式 提取需要的内容
如果你一定要说应该改的地方都改了,我只能说你人品有问题了。