爱问知识人 爱问教育 医院库

SQL Server企业管理器如何加入图片?

首页

SQL Server企业管理器如何加入图片?

我在SQL中加入数据时,photo字段因为设为图像类别无法加入,请朋友帮忙,如何运用企业管理器,添加图片或图片文件夹的信息?

提交回答
好评回答
  • 2007-02-03 16:09:30
      有两种方法, 
    一种是只存图片所放在服务器的路径,只要存放varchar格式就可以了。 
    这种方法比较好。不占用数据库太大,但是服务器需要解析路径。 
    一种是存放二进制的数据Image类型。sqlserver提供了。在程序中要用流文件的形式,以下是我在网上找到的资料,希望对你有帮助: 
    保存images进SQL Server数据库 
    为了保存图片到table你首先得从客户端上传它们到你的web服务器。
      你可以创建一个web form,用TextBox得到图片的标题,用HTML File Server Control得到图片文件。确信你设定了Form的encType属性为multipart/form-data。 Stream imgdatastream = File1。
      PostedFile。InputStream; int imgdatalen = File1。PostedFile。ContentLength; string imgtype = File1。PostedFile。ContentType; string imgtitle = TextBox1。
      Text; byte[] imgdata = new byte[imgdatalen]; int n = imgdatastream。Read(imgdata,0,imgdatalen); string connstr= ((NameValueCollection)Context。
      GetConfig ("appSettings"))["connstr"]; SqlConnection connection = new SqlConnection(connstr); SqlCommand command = new SqlCommand ("INSERT INTO ImageStore(imgtitle,imgtype,imgdata) VALUES ( @imgtitle, @ )", connection ); SqlParameter paramTitle = new SqlParameter ("@imgtitle", SqlDbType。
      VarChar,50 ); paramTitle。Value = imgtitle; command。Parameters。Add( paramTitle); SqlParameter paramData = new SqlParameter ( "@imgdata", SqlDbType。
      Image ); paramData。Value = imgdata; command。Parameters。Add( paramData ); SqlParameter paramType = new SqlParameter ( "@imgtype", SqlDbType。
      VarChar,50 ); paramType。Value = imgtype; command。Parameters。Add( paramType ); connection。Open(); int numRowsAffected = command。
      ExecuteNonQuery(); connection。Close(); 。

    雪***

    2007-02-03 16:09:30

其他答案

    2007-01-29 16:37:04
  • 不能在企业管理器中直接向字段加入图片,可以考虑用VB、VC、PB、DELPHI、C#等开发工具写程序来加。

    x***

    2007-01-29 16:37:04

  • 2007-01-26 23:46:51
  • img类型应该可以,代码发一下

    m***

    2007-01-26 23:46:51

类似问题

换一换
  • 程序设计 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):