这是一个SQLite数据库的存取照片问题

那位大佬帮我写下ASP网站下 sqlite数据库存取照片的代码啊,网上搜的要改好多,我不会啊!
那位大佬帮我写下ASP网站下 sqlite数据库存取照片的代码啊,网上搜的要改好多,我不会啊!

给你完整做了一个

代码下载:https://download.csdn.net/download/caozhy/11580879

图片说明

default.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SQLite;
using System.Data;

namespace Q773503
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var img = FileUpload1.FileBytes;
            var datapath = Server.MapPath("~/App_Data/");
            SQLiteConnection conn = new SQLiteConnection("data source=" + datapath + "db.db3;version=3;");
            conn.Open();
            SQLiteCommand cmd = new SQLiteCommand();
            cmd.CommandText = "INSERT INTO tb(img) VALUES(@im)";
            SQLiteParameter param = new SQLiteParameter("@im", DbType.Binary, img.Length, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, img);
            cmd.Parameters.Add(param);
            cmd.Connection = conn;
            cmd.ExecuteNonQuery();
            Response.Redirect("showimg.aspx");
        }
    }
}

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="Q773503._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome to ASP.NET!
    </h2>
    <p>
        To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
    </p>
    <p>
        You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
            title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
    </p>
    <asp:FileUpload ID="FileUpload1" runat="server" />
    <br />
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</asp:Content>

showimage.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SQLite;
using System.Data;

namespace Q773503
{
    public partial class showimg : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var datapath = Server.MapPath("~/App_Data/");
            SQLiteConnection conn = new SQLiteConnection("data source=" + datapath + "db.db3;version=3;");
            conn.Open();
            SQLiteCommand cmd = new SQLiteCommand();
            cmd.CommandText = "SELECT * FROM tb ORDER BY id DESC";
            cmd.Connection = conn;
            var reader = cmd.ExecuteReader();
            reader.Read();
            Response.ContentType = "image/jpeg";
            Response.OutputStream.Write((byte[])reader["img"], 0, ((byte[])reader["img"]).Length);
            Response.End();
        }
    }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="showimg.aspx.cs" Inherits="Q773503.showimg" %>