最近捣鼓了一下,效果就是这样:
图1:
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示

图2:
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示

ImageFileUpload.aspx:

Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ImageFileUpload.aspx.cs" Inherits="ImageFileUpload" %>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
<html xmlns="http://www.w3.org/1999/xhtml" >
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
<head runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示    
<title>图片保存和显示</title>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
</head>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
<body>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示    
<form id="Form2" enctype="multipart/form-data" runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
<asp:Table ID="Table1" Runat="server" Width="39%" BorderWidth="1" BackColor="Beige">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<asp:TableRow runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell ColumnSpan="2" BackColor="Red" runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:Label ID="Label1" Font-size="12px" ForeColor="White" font-bold="True" Runat="server" Text="添加" Font-Names="verdana" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
</asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
</asp:TableRow>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<asp:TableRow runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell HorizontalAlign="Right" runat="server"><asp:Label ID="Label2" Font-size="12px"  Runat="server" Text="名字" Font-Names="verdana" /></asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell runat="server"><asp:TextBox id="txtPersonName" Runat="server" /></asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
</asp:TableRow>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<asp:TableRow runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell HorizontalAlign="Right" runat="server"><asp:Label ID="Label3" Font-size="12px"  Runat="server" Text="Email" Font-Names="verdana" /></asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell runat="server"><asp:TextBox id="txtPersonEmail" Runat="server" /></asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
</asp:TableRow>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<asp:TableRow runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell HorizontalAlign="Right" runat="server"><asp:Label ID="Label4" Font-size="12px"  Runat="server" Text="性别" Font-Names="verdana" /></asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                                
<asp:RadioButton GroupName="sex"  Font-Size="12px" Text="男性" ID="sexMale" Runat="server"   Checked="true" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                                
<asp:RadioButton GroupName="sex"  Font-Size="12px" Text="女性" ID="sexFeMale" Runat="server" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
</asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
</asp:TableRow>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<asp:TableRow runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell HorizontalAlign="Right" runat="server"><asp:Label ID="Label5" Font-size="12px"  Runat="server" Text="生日" Font-Names="verdana" /></asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell runat="server"><asp:TextBox id="txtPersonDob" runat="server" /></asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
</asp:TableRow>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<asp:TableRow runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell HorizontalAlign="Right" runat="server"><asp:Label ID="Label6" Font-size="12px"  Runat="server" Text="图片" Font-Names="verdana" /></asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell runat="server"><input type="file" id="PersonImage" runat="server" /></asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
</asp:TableRow>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<asp:TableRow runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:TableCell ColumnSpan="2" HorizontalAlign="Center" runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:Button ID="Button1" Text="添加" OnClick="AddPerson" runat="server" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
</asp:TableCell>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
</asp:TableRow>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
</asp:Table>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示        
<br />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示        
<table>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
<tr>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td align="left" valign="top" style="width: 181px">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                    
<asp:Label ID="Label_Message" runat="server" Font-Size="10pt"></asp:Label></td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td style="width: 7px">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td align="left" style="width: 18px" valign="top">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
</tr>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
<tr>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td style="width: 181px;" align="left" valign="top">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                    
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="PersonID" DataSourceID="SqlDataSource_SelectImage" ForeColor="#333333" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Font-Size="10pt" Width="200px" BackColor="#FFE0C0">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<Columns>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                            
<asp:TemplateField HeaderText="序号" InsertVisible="False" SortExpression="PersonID">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                
<EditItemTemplate>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:Label ID="Label1" runat="server" Text='<%# Eval("PersonID") %>'></asp:Label>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                
</EditItemTemplate>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                
<ItemTemplate>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                    
<asp:Label ID="Label1" runat="server" Text='<%# Bind("PersonID") %>'></asp:Label>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                
</ItemTemplate>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                
<HeaderStyle Width="35px" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                            
</asp:TemplateField>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                            
<asp:BoundField DataField="PersonName" HeaderText="名字" SortExpression="PersonName" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                            
<asp:BoundField DataField="PersonImageType" HeaderText="图片类型" SortExpression="PersonImageType" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                            
<asp:CommandField ShowSelectButton="True" >
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                                
<ItemStyle Width="30px" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                            
</asp:CommandField>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
</Columns>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<RowStyle BackColor="#EFF3FB" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<EditRowStyle BackColor="#2461BF" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<HeaderStyle BackColor="Red" Font-Bold="True" ForeColor="White" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                        
<AlternatingRowStyle BackColor="White" />
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                    
</asp:GridView>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td style="width: 7px; height: 180px;">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td align="left" style="width: 18px; height: 180px;" valign="top">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                    
<asp:Image ID="Image_Show" runat="server" /></td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
</tr>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
<tr>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td style="width: 181px">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                    
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td style="width: 7px">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td style="width: 18px">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
</tr>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
<tr>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td style="width: 181px; height: 21px;">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td style="width: 7px; height: 21px;">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
<td style="width: 18px; height: 21px;">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示                
</td>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            
</tr>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示        
</table>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示        
<asp:SqlDataSource ID="SqlDataSource_SelectImage" runat="server" ConnectionString="<%$ ConnectionStrings:ImageSelect_ConnectionString %>"
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示            SelectCommand
="SELECT PersonID, PersonName, PersonImageType FROM Person"></asp:SqlDataSource>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示    
</form>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
</body>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
</html>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示

ImageFileUpload.aspx.cs:
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示using System;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Data;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Configuration;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Collections;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.Security;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.UI;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.UI.WebControls;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.UI.WebControls.WebParts;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.UI.HtmlControls;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Data.SqlClient;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.IO;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
public partial class ImageFileUpload : System.Web.UI.Page

ImageShow.aspx:(显示图片)
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ImageShow.aspx.cs" Inherits="ImageShow" %>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
<html xmlns="http://www.w3.org/1999/xhtml" >
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
<head runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示    
<title>无标题页</title>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
</head>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
<body>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示    
<form id="form1" runat="server">
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示    
<div>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示    
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示    
</div>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示    
</form>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
</body>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
</html>
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示

ImageShow.aspx.cs:

Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示using System;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Data;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Configuration;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Collections;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.Security;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.UI;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.UI.WebControls;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.UI.WebControls.WebParts;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Web.UI.HtmlControls;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
using System.Data.SqlClient;
Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
public partial class ImageShow : System.Web.UI.Page


最后一个存储过程:
Drop Table Person

Go

 

Create Table Person

(

PersonID Int Identity,

PersonEmail Varchar(255),

PersonName Varchar(255),

PersonSex Char(1),

PersonDOB DateTime,

PersonImage Image,

PersonImageType Varchar(255)

)

 

Drop Proc sp_person_isp

Go

 

Create Proc sp_person_isp

@PersonEmail Varchar(255),

@PersonName Varchar(255),

@PersonSex Char(1),

@PersonDOB DateTime,

@PersonImage Image,

@PersonImageType Varchar(255)

As

Begin

            Insert into Person

                        (PersonEmail, PersonName, PersonSex,

                         PersonDOB, PersonImage, PersonImageType)

            Values

                        (@PersonEmail, @PersonName, @PersonSex,

                         @PersonDOB, @PersonImage, @PersonImageType)

End

 

Go

相关文章: