- 分享
- 0
- 人气
- 0
- 主题
- 10
- 帖子
- 30
- UID
- 445283
- 积分
- 24
- 阅读权限
- 11
- 注册时间
- 2011-9-22
- 最后登录
- 2012-10-15
- 在线时间
- 36 小时
|
这个是连接 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, |
|