我写了一段上传的程序,为什么可以上传到文件夹里,但却没有把文件标题,创建时间等记录到数据库里呢?
解决方案 »
- C# 第一次启动时的提示窗体怎样实现
- 请教一个XPath的问题
- C#制作点唱系统!
- 想问一个java的功能.net有没有
- 急急急,Oracle 9i客户端连接Oracle8i的服务器乱码问题。
- 如何在下来菜单中添加treeview
- C#中有没有类似STL的数据结构包
- 一个office文档嵌入的小程序,为什么程序本机运行正常,发布后就闪退?
- C# 动态生成xm schema 文件
- 要放假啦,想看XML方面的书,请您推荐几本?
- 动态加载DLL时,使用asm.GetType("xx.dll") 返回值为null?
- 问:1:如何用XML写简历2:上传文件且有限制文件大小,以及文件类型3:iframe的使用4:读写PDF文件
{
string str = this.FileUpload1.PostedFile.FileName;
string filepath;
string ss = str.Substring(str.LastIndexOf("\\") + 1);
string s = Server.MapPath("..\\neos\\" + ss);
filepath = "..\\neos\\" + ss;
bool bl = ExecSQL("INSERT INTO [file3](fileDescription,filepath)VALUES('" + TextBox1.Text + "','" + filepath + "')");
if (bl)
{
Response.Write("<script language = javascript>alert(\"上传文件成功!\")</script>");
}
else
{
Response.Write("<script language = javascript>alert(\"上传文件失败!\")</script>");
}
if (str == string.Empty) return;
this.FileUpload1.PostedFile.SaveAs(s);
} public Boolean ExecSQL(string sQueryString)
{
string ConnectionString = "Data Source=localhost;Initial Catalog=abs;Persist Security Info=True;User ID=sa;Password=m123";
SqlConnection cn = new SqlConnection(ConnectionString);
SqlCommand dbCommand = new SqlCommand(sQueryString, cn);
try
{
dbCommand.ExecuteNonQuery();
cn.Close();
}
catch (SystemException e)
{
cn.Close();
return false;
}
return true;
}