asp.net产品发布系统(读取二进制数据库文件)
选择产品型号:dropdownlist1
添加产品图片:FileUpload1
产品介绍:textbox1
button 提交 到数据库 Products表中 相应的字段 productModel productImage productInfo 做成功了
button—click 事件 代码
部分代码如下
SqlConnection scn = new SqlConnection();
SqlCommand scm = new SqlCommand();
scn.ConnectionString = "Data Source=SZIEC-DC68911A7;Initial Catalog=MFG;Integrated Security=True";
scm.Connection = scn;
scm.CommandType = CommandType.Text;
if (FileUpload1.HasFile)
{
//上传图片
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName); //获取文件名
string extName = Path.GetExtension(filename); //获取扩展名
string NewPath_name = "Image/" + filename;
FileUpload1.PostedFile.SaveAs(HttpContext.Current.Request.MapPath("~/").ToString() + NewPath_name);
scm.CommandText = "Insert Into Products(productModel,productImage,productDetailInfo,pr。。。。。。。。
scn.Open();
scm.ExecuteNonQuery();
scn.Close();
提交过后 放到本地 Image文件夹里了 数据库里的如下
编号 productImage productInfo productModel
30 <二进制数据> dfasfasfasf LM-M0N0TCTLW4(2.8TFT) sdfas NULL
想在做一个 网页 滚动图片 抓取 productImage图片 然后点击 就进入 一个产品详细信息网页
可以做成功的一个是 把产品型号 做成链接 动态发布
部分代码如下
<P>产品型号:<asp:Label ID="Label1" runat="server" Text='<%# Eval("productModel") %>'
Font-Bold="True"></asp:Label></P><hr />
<p>产品图片:</p>
<p>
<asp:Image ID="Image1" runat="server" Height="112px" Width="159px" /></p>
<hr />
<p>产品详细介绍;</p>
<p>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</p>
<p>上传时间:<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</p>
<p>产品生产日期:<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
后台
string id = Request.QueryString["id"];
string strconn = "Data Source=SZIEC-DC68911A7;Initial Catalog=MFG;Integrated Security=True";
DataSet ds = new DataSet();
; SqlDataAdapter da = new SqlDataAdapter("select * from Products where productId =" + id, strconn);
da.Fill(ds, "Products");
da.Dispose();
if (ds.Tables.Count != 0)
{
Label1.Text = ds.Tables[0].Rows[0]["productModel"].ToString();
Label2.Text = ds.Tables[0].Rows[0]["productInfo"].ToString();
Label4.Text=ds.Tables[0].Rows[0]["productImage"].ToString();
Image1.ImageUrl = ds.Tables[0].Rows[0]["productImage"].ToString();
}
}
为什么 做了个测试 为什么 ds.Tables[0].Rows[0]["productImage"].ToString(); 是 System.Byte[] 》?
如何动态发布产品 在主页滚动 单击图片 产生链接
太困了 就先发到这里把 期待 好心人了啊