protected void Button1_Click(object sender, EventArgs e)
{
this.SqlDataSource1.Insert();
string filepath = "", filename = "", mfilename, mfilepath;
if(""!=FileUpload1.PostedFile.FileName)
{
filepath = FileUpload1.PostedFile.FileName;
filename = filepath.Substring(filepath.LastIndexOf(".") + 1);
try
{
mfilepath = Server.MapPath("ima/");
mfilename = filepath.Substring(filepath.LastIndexOf("\\") + 1);
string strsql = "insert into userinfo(imagepath)values('" + mfilepath + "')";
con = new SqlConnection(strCon);
con.Open();
SqlCommand cmd = new SqlCommand(strsql, con);
cmd.ExecuteNonQuery();
con.Close();//这句怎么不执行????
}
catch { Response.Write("<scrip>alert('上传文件不存在')</scrip>"); }
}