Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
查看: 1457|回复: 0
打印 上一主题 下一主题

高手ASP.NET uploading问题?

[复制链接]

10

主题

0

好友

24

积分

初级会员

Rank: 1

跳转到指定楼层
1#
发表于 2012-9-4 03:59 PM |只看该作者 |倒序浏览
这个是连接  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,




收藏收藏0
您需要登录后才可以回帖 登录 | 注册

回顶部