惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
Hacker News: Ask HN
Hacker News: Ask HN
L
Lohrmann on Cybersecurity
PCI Perspectives
PCI Perspectives
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
月光博客
月光博客
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
The GitHub Blog
The GitHub Blog
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
TaoSecurity Blog
TaoSecurity Blog
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
F
Full Disclosure
U
Unit 42
Jina AI
Jina AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
T
Troy Hunt's Blog
腾讯CDC
T
Threatpost
H
Hacker News: Front Page
P
Palo Alto Networks Blog
博客园 - 聂微东
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
Help Net Security
Help Net Security
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Spread Privacy
Spread Privacy

博客园 - joyous jeny

Log4Net advanced pattern tips SQLServer的TDE加密 Forrest Gump frontend learning site JDK JRE区别 用户中心 - 博客园 用户中心 - 博客园 用户中心 - 博客园 转:jQuery设计思想 marked ASP.NET 页面对象模型 3种方法从Html中取文本 WebResource - joyous jeny - 博客园 让DropDownlist显示ToolTip(两部分) - joyous jeny - 博客园 Tech tips(回发、显示名称、DataView过滤前10条记录) - joyous jeny ASP脚本里加事务 Make a mark of Gates .net 20 callback example 导出Datagrid里所有数据到excel - joyous jeny - 博客园 比较经典的日期判断 - joyous jeny - 博客园
图片的存取
joyous jeny · 2011-03-24 · via 博客园 - joyous jeny

 //存图片到DB
    private void button1_Click(object sender, EventArgs e)
    {
        Stream ms;
        byte[] picbyte;
        OpenFileDialog ofdSelectPic = new OpenFileDialog();
        ofdSelectPic.ShowDialog();
        string f = ofdSelectPic.FileName;

        ms = ofdSelectPic.OpenFile();
        picbyte = new byte[ms.Length];
        ms.Position = 0;
        ms.Read(picbyte, 0, Convert.ToInt32(ms.Length));

        SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=;database=s");
        conn.Open();
        string sqlstring = "insert into ttt(image) values(@img)";
        SqlCommand cmd = new SqlCommand(sqlstring, conn);
        cmd.Parameters.Add("@img", SqlDbType.Image, picbyte.Length).Value = picbyte;

        cmd.ExecuteNonQuery();
        conn.Close();
    }
    //由数据取图片

    private void button2_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection("server=.;uid=sa;pwd=;database=s");
        conn.Open();
        string strSql = "select image from ttt ";
        SqlCommand cmd = new SqlCommand(strSql, conn);
        SqlDataReader sdr = cmd.ExecuteReader();
        sdr.Read();
        MemoryStream ms = new MemoryStream((byte[])sdr[0]);
        Image image = Image.FromStream(ms);
        sdr.Close();
        conn.Close();
        pictureBox1.Image = image;
    }