使用C#Windows在Access数据库中插入图像 [英] insert image in access database using c# windows

查看:78
本文介绍了使用C#Windows在Access数据库中插入图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
可以共享一些代码,以使用c#,Windows窗体应用程序在ms Access数据库中插入图像

感谢

解决方案

这是我使用的SQL版本-访问版本是相同的,不同之处在于,将SqlConnection和SqlCommand替换为所使用的内容. "cs"> 使用(SqlConnection con = SqlConnection(connectionString)) { 使用(SqlCommand com = SqlCommand(" 插入myTable(myImage)值(@IM)",con)) { 字节 [] imageData = File.ReadAllBytes( @" ); com.Parameters.AddWithValue(" ,imageData); com.ExecuteNonQuery(); } }


http://cs.pervasive.com/forums /t/717.aspx [^ ]

http://stackoverflow.com/questions/8666718/how-can- i-insert-image-in-access-table [ ^ ]

http://www.daniweb.com/software-development/csharp/threads/263533/retrieving-pic-from-access-database-to-picture-box-using-c [ 解决方案

This is the SQL version I use - the access version is the same, except you replace the SqlConnection and SqlCommand with whatever you are using.

using (SqlConnection con = new SqlConnection(connectionString))
    {
    using (SqlCommand com = new SqlCommand("INSERT INTO myTable (myImage) VALUES (@IM)", con))
        {
        byte[] imageData = File.ReadAllBytes(@"F:\Temp\Picture.jpg");
        com.Parameters.AddWithValue("@IM", imageData);
        com.ExecuteNonQuery();
        }
    }


http://cs.pervasive.com/forums/t/717.aspx[^]

http://stackoverflow.com/questions/8666718/how-can-i-insert-image-in-access-table[^]

http://www.daniweb.com/software-development/csharp/threads/263533/retrieving-pic-from-access-database-to-picture-box-using-c[^]


convert image to bytearray and store it to access and same way retrive that array and convert again back to image


这篇关于使用C#Windows在Access数据库中插入图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆