小弟:通过下面的代码.
来保存图片.
this.openFileDialog1.ShowDialog();
Stream s ;
//this.openFileDialog1.ShowDialog();
if ( this.openFileDialog1.OpenFile()!= null )
{
s = this.openFileDialog1.OpenFile();
byte[] bytes = new byte[s.Length];
s.Read(bytes,0,bytes.Length);
SqlConnection con = new SqlConnection("server = .. ; database =..; uid = ..; password =..;");
string sql = "insert into picteset (pic ) values ('"+ bytes +"') ";
SqlCommand cmd = new SqlCommand(sql , con ); cmd.Connection.Open();
for(int i =0 ; i<1 ;i++)
{
cmd.ExecuteNonQuery();
}
cmd.Connection.Close();
Bitmap bm = new Bitmap(s); this.pictureBox1.Image = bm;
s.Close();数据表如下:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[picteset]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[picteset]
GOCREATE TABLE [dbo].[picteset] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[pic] [image] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO在汇入图片的时候,我可以在debug的过程中,看到bytes的长度明明是 771402 。
但是,真正汇入到数据库中的只有 这样一段 0x53797374656D2E427974655B5D
当我,再次取出来的时候,发现取出来的数组中 ,长度只有13 。
非常奇怪,
那个高手,能不能说说为啥
来保存图片.
this.openFileDialog1.ShowDialog();
Stream s ;
//this.openFileDialog1.ShowDialog();
if ( this.openFileDialog1.OpenFile()!= null )
{
s = this.openFileDialog1.OpenFile();
byte[] bytes = new byte[s.Length];
s.Read(bytes,0,bytes.Length);
SqlConnection con = new SqlConnection("server = .. ; database =..; uid = ..; password =..;");
string sql = "insert into picteset (pic ) values ('"+ bytes +"') ";
SqlCommand cmd = new SqlCommand(sql , con ); cmd.Connection.Open();
for(int i =0 ; i<1 ;i++)
{
cmd.ExecuteNonQuery();
}
cmd.Connection.Close();
Bitmap bm = new Bitmap(s); this.pictureBox1.Image = bm;
s.Close();数据表如下:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[picteset]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[picteset]
GOCREATE TABLE [dbo].[picteset] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[pic] [image] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO在汇入图片的时候,我可以在debug的过程中,看到bytes的长度明明是 771402 。
但是,真正汇入到数据库中的只有 这样一段 0x53797374656D2E427974655B5D
当我,再次取出来的时候,发现取出来的数组中 ,长度只有13 。
非常奇怪,
那个高手,能不能说说为啥
解决方案 »
- 开发 DirectShow 播放器时如何加入 DirectVobSub 字幕 filter?
- using 用法如何理解
- 请各位帮忙根据上面这三表表把以下两条SQL语句合并成一条,谢谢了。
- WinForm下,关于数据库连接的问题.
- 求助,不能获得正确的输入输出
- C#连接EXCEL2013
- 请教正则表达式的问题 (网页html操作)
- 請教﹕WebForm中如何連Oracle8i?
- 如何把DataGrid的标题设置为超链接?
- 请问以.iso后缀名结尾文件是什么类型的文件,我要安装什么软件,才可以运用这类文件?
- JMAIL收邮件问题,已经可以收邮件了,但是在收完一次且delete之后,再去收,为什么收到的还是第一次收的呢(注:在delete之后,我也disco
- 求助AxSHDocVw.AxWebBrowser的一个问题,高手请进!
参看
http://blog.csdn.net/knight94/archive/2006/03/24/637800.aspx