不再回头 .net学习日记&资料

我再也不愿听你要求 我受够了你那些自私要求

  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  39 随笔 :: 2 文章 :: 14 评论 :: 0 Trackbacks
Byte[] FileByteArray  =   new  Byte[iFileLength];
            Stream StreamObject 
=  upFile.InputStream;
            StreamObject.Read(FileByteArray, 
0 , iFileLength);
            SqlConnection conn 
=   new  SqlConnection( " server=yy;uid=sa;pwd=;database=pany " );
            
string  sql  =   " insert into t_imgs (imgData, type, description, imgSize) values  "  
                
+   " (@Image, @ContentType, @ImageDescription, @ImgSize) " ;
            SqlCommand cmd 
=   new  SqlCommand(sql, conn);
            cmd.Parameters.Add(
" @Image " , SqlDbType.Binary, iFileLength).Value  =  FileByteArray;
            cmd.Parameters.Add(
" @ContentType " , SqlDbType.VarChar,  50 ).Value  =  upFile.ContentType;
            cmd.Parameters.Add(
" @ImageDescription " , SqlDbType.VarChar,  200 ).Value  =  txtDesc.Text;
            cmd.Parameters.Add(
" @ImgSize " , SqlDbType.BigInt,  8 ).Value  =  upFile.ContentLength;
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
posted on 2006-09-13 21:34 不再回头 阅读(1019) 评论(1)  编辑 收藏 引用 所属分类: SQL

评论

# re: sql 插入 图片 2009-09-06 22:11 gwz
读出来显示怎么写呢?  回复  更多评论
  

只有注册用户登录后才能发表评论。