[英]Saving multiple Images at once to the database with a FileUpload Control
[英]fileupload value is not saving in database
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand("insert into Tbl_Videos(VideoName,VideoPath)values(@VideoName,@VideoPath)");
string fileExt = System.IO.Path.GetExtension(FileUpload1.FileName);
if (fileExt == ".avi")
{
try
{
FileUpload1.SaveAs(Server.MapPath("~/video/" +FileUpload1.FileName));
Label1.Text = "File name: " +
FileUpload1.PostedFile.FileName + "<br>" +
FileUpload1.PostedFile.ContentLength + " kb<br>" +"Content type: "+FileUpload1.PostedFile.ContentType;
cmd.Parameters.AddWithValue("@VideoName",FileUpload1.FileName);
cmd.Parameters.AddWithValue("@VideoPath", FileUpload1.FileName);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
}
else
{
Label1.Text = "Only .avi files allowed!";
}
}
您在哪里提到您的SQL Server连接字符串?
SqlConnection con = new SqlConnection(YOUR_CONNECTION_STRING_HERE);
con.Open();
然后执行查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.