• devexpress datagrid 与imageEdit以及如何存图片到数据库


    首先建立了一个数据库的表,这个表中,有一个字段是image类型(SQL Server数据库)

    USE [SchedulerDB]
    GO 
    
    /****** Object:  Table [dbo].[Resources]    Script Date: 11/19/2014 10:16:03 ******/
    IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Resources]') AND type in (N'U'))
    DROP TABLE [dbo].[Resources]
    GO
    
    USE [SchedulerDB]
    GO 
    
    /****** Object:  Table [dbo].[Resources]    Script Date: 11/19/2014 10:16:03 ******/
    
    SET ANSI_NULLS ON
    GO 
    
    SET QUOTED_IDENTIFIER ON
    GO 
    
    CREATE TABLE [dbo].[Resources](
        [UniqueID] [int] IDENTITY(1,1) NOT NULL,
        [ResourceID] [int] NOT NULL,
        [ResourceName] [nvarchar](50) NULL,
        [Color] [int] NULL,
        [Image] [image] NULL,
        [CustomField1] [nvarchar](max) NULL,
     CONSTRAINT [PK_Resources] PRIMARY KEY CLUSTERED 
    (
        [UniqueID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO 
    
    EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'岗位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Resources'
    GO 

    然后与datagrid进行了映射。

    然后,在image字段上,绑定一个ImageEdit编辑控件。

    然后运行,

    然后,就得到这个错误:Object must implement IConvertible

    把PictureStoreMode改成ByteArray

    然后就OK了。

    对了,保存所对应的代码为:

    void saveToolStripButton_Click(object sender, EventArgs e)
     {
         this.Validate();
         this.resourcesBindingSource.EndEdit();
         this.resourcesTableAdapter.Update(this.schedulerDBDataSet);
         schedulerDBDataSet.AcceptChanges();
     } 
  • 相关阅读:
    vs2017启动iis局域网无法访问解决
    centos7多节点部署redis4.0.11集群
    centos7用docker安装elasticsearch5.6.13的主从
    centos7用docker安装单节点redis4.0.11
    centos7用docker安装mysql5.7.24后配置主从
    centos7 docker 安装 mysql5.7.24 导入12G的sql
    局域网内搭建一个服务器,可以使用 https 吗
    nginx负载均衡fair模块安装和配置
    腿伤中,继续养...
    文件Move操作
  • 原文地址:https://www.cnblogs.com/MuNet/p/5736185.html
Copyright © 2020-2023  润新知