JBTALKS.CC
标题:
高手ASP.NET uploading问题?
[打印本页]
作者:
new_programmer
时间:
2012-9-4 03:59 PM
标题:
高手ASP.NET uploading问题?
这个是连接
http://www.c-sharpcorner.com/upl ... images-to-database/
After some correction, " p.ProductType = txtName.Text;" the "p" in Presentation layer still got problems. What is the problem? Thanks!
Presentation Layer
You have to write the code under Button:
protected void Button2_Click(object sender, EventArgs e)
{
lblMessage.Visible = true;
p
.ProductType = txtName.Text;
if (FileUpload1.PostedFile != null &&
FileUpload1.PostedFile.FileName != "")
{
byte[] imageSize = new byte
[FileUpload1.PostedFile.ContentLength];
HttpPostedFile uploadedImage = FileUpload1.PostedFile;
uploadedImage.InputStream.Read
(imageSize, 0, (int)FileUpload1.PostedFile.ContentLength);
p
.Image = imageSize;
}
p
.InsertProducts();
lblMessage.Text = "File Uploaded";
}
Business Access Layer
public void InsertProducts()
{
SqlParameter[] p=new SqlParameter[2];
p[0]=new SqlParameter("@ProductType",producttype);
p[0].DbType=DbType.String;
p[1]=new SqlParameter("Image",image);
SqlHelper.ExecuteNonQuery(clsConnection.Connection,
欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/)
Powered by Discuz! X2.5