zoukankan      html  css  js  c++  java
  • devexpress datagrid 与imageEdit以及如何存图片到数据库 z

    http://blog.csdn.net/haoyujie/article/details/41277703

    首先建立了一个数据库的表,这个表中,有一个字段是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();
            }
    
  • 相关阅读:
    [HAOI2014]贴海报
    【模板】高斯消元法
    2015FAI
    ASP.NET网站图标,始终不显示是怎么回事
    小说自动生成项目
    电脑写小说可行吗?(四)情绪的本质
    电脑写小说可行吗?(三)智能体
    电脑写小说可行吗?(二)情感理论
    电脑写小说可行吗? (一)电脑能做什么
    留言板
  • 原文地址:https://www.cnblogs.com/zeroone/p/4176893.html
Copyright © 2011-2022 走看看