Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 995|回复: 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,
CommandType.StoredProcedure, "sp_InsertProducts", p);
    }
// Here "sp_InsertProducts" is the stored procedure Name.

Data Access Layer

public class clsConnection
{
      public clsConnection()
      {
            //
            // TODO: Add constructor logic here
            //
      }
    public static string Connection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
}

Under W




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

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-12-26 03:36 PM , Processed in 0.105932 second(s), 27 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部