转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 数据库 >> Sql Server >> 正文
利用C#在SQL Server2000存取图像 For Window         

利用C#在SQL Server2000存取图像 For Window

作者:闵涛 文章来源:闵涛的学习笔记 点击数:3045 更新时间:2007/11/14 11:06:26

数据库表:

CREATE TABLE [TABLE1] (
 [id] [int] IDENTITY (1, 1) NOT NULL ,
 [img] [image] NULL ,
 [name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

程序代码:

黑体字部分为主要代码

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication1
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  private System.Windows.Forms.OpenFileDialog openFileDialog1;
  private System.Data.SqlClient.SqlCommand sqlCommand1;
  private System.Data.SqlClient.SqlConnection sqlConnection1;
  private System.Windows.Forms.ListBox listBox1;
  private System.Windows.Forms.Splitter splitter1;
  private System.Windows.Forms.Panel panel1;
  private System.Windows.Forms.Button button2;
  private System.Windows.Forms.Button button1;
  private System.Windows.Forms.ContextMenu contextMenu1;
  private System.Windows.Forms.MenuItem menuItem1;
  private System.Windows.Forms.SaveFileDialog saveFileDialog1;
  private System.Windows.Forms.Panel panel2;
  private System.Windows.Forms.PictureBox pictureBox1;
  private System.Windows.Forms.MenuItem menuItem2;
  private System.Windows.Forms.MenuItem menuItem3;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
   this.sqlCommand1 = new System.Data.SqlClient.SqlCommand();
   this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
   this.listBox1 = new System.Windows.Forms.ListBox();
   this.splitter1 = new System.Windows.Forms.Splitter();
   this.panel1 = new System.Windows.Forms.Panel();
   this.button2 = new System.Windows.Forms.Button();
   this.button1 = new System.Windows.Forms.Button();
   this.contextMenu1 = new System.Windows.Forms.ContextMenu();
   this.menuItem1 = new System.Windows.Forms.MenuItem();
   this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
   this.panel2 = new System.Windows.Forms.Panel();
   this.pictureBox1 = new System.Windows.Forms.PictureBox();
   this.menuItem2 = new System.Windows.Forms.MenuItem();
   this.menuItem3 = new System.Windows.Forms.MenuItem();
   this.panel1.SuspendLayout();
   this.panel2.SuspendLayout();
   this.SuspendLayout();
   //
   // listBox1
   //
   this.listBox1.Dock = System.Windows.Forms.DockStyle.Left;
   this.listBox1.ItemHeight = 12;
   this.listBox1.Location = new System.Drawing.Point(0, 0);
   this.listBox1.Name = "listBox1";
   this.listBox1.Size = new System.Drawing.Size(176, 412);
   this.listBox1.TabIndex = 4;
   //
   // splitter1
   //
   this.splitter1.Location = new System.Drawing.Point(176, 0);
   this.splitter1.Name = "splitter1";
   this.splitter1.Size = new System.Drawing.Size(3, 421);
   this.splitter1.TabIndex = 5;
   this.splitter1.TabStop = false;
   //
   // panel1
   //
   this.panel1.Controls.Add(this.button2);
   this.panel1.Controls.Add(this.button1);
   this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
   this.panel1.Location = new System.Drawing.Point(179, 349);
   this.panel1.Name = "panel1";
   this.panel1.Size = new System.Drawing.Size(469, 72);
   this.panel1.TabIndex = 6;
   //
   // button2
   //
   this.button2.Location = new System.Drawing.Point(152, 16);
   this.button2.Name = "button2";
   this.button2.Size = new System.Drawing.Size(208, 40);
   this.button2.TabIndex = 4;
   this.button2.Text = "选择图片存入数据库";
   this.button2.Click += new System.EventHandler(this.button2_Click_1);
   //
   // button1
   //
   this.button1.Location = new System.Drawing.Point(216, 16);
   this.button1.Name = "button1";
   this.button1.Size = new System.Drawing.Size(88, 32);
   this.button1.TabIndex = 5;
   this.button1.Text = "读取";
   this.button1.Visible = false;
   //
   // contextMenu1
   //
   this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                       this.menuItem1,
                       this.menuItem2,
                       this.menuItem3});
   //
   // menuItem1
   //
   this.menuItem1.Index = 0;
   this.menuItem1.Text = "另存";
   //this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
   //
   // panel2
   //
   this.panel2.AutoScroll = true;
   this.panel2.Controls.Add(this.pictureBox1);
   this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
   this.panel2.Location = new System.Drawing.Point(179, 0);
   this.panel2.Name = "panel2";
   this.panel2.Size = new System.Drawing.Size(469, 349);
   this.panel2.TabIndex = 7;
   //
   // pictureBox1

[1] [2] [3]  下一页


[系统软件]InstallShield Express for delphi制作安装程序定…  [系统软件](转帖) 忘记登录密码的解决方案 for XP/2003/2000
[系统软件]交叉编译sshd for IXP425 ARM  Platform by MVL 3…  [Delphi程序]《关于VisiBroker For Delphi的使用》(4)
[Delphi程序]一个超链接Image控件!(For D3,D4,D5,D6)源代码  [Delphi程序]Five of the best tools for Delphi
[Delphi程序]《关于VisiBroker For Delphi的使用》(3)  [Delphi程序]《关于VisiBroker For Delphi的使用》(2)
[Delphi程序]《关于VisiBroker For Delphi的使用》  [Delphi程序]Delphi for .Net 编译器预览 - by John Kaster
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Sql Server  · MySql
    · Access  · ORACLE
    · SyBase  · 其他
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台