转至繁体中文版     | 网站首页 | 文章中心 | 下载中心 | 图片中心 | 笑话频道 | 教程频道 | 会员中心 | 雁过留声 | 
最新公告:     "MinTao学以致用网"欢迎您的光临,你的支持便是我们的动力,欢迎广大网友和各界人士亲临指导,你们的一个小小的建议便是我们发展的开路石!  [MinTao  2007年9月5日]        
您现在的位置: MinTao学以致用网 >> 文章中心 >> 电子课堂 >> 数据库 >> Sql Server >> 文章正文
专题栏目
更多内容
最新推荐 更多内容
相关文章
[PL/SQL] 用For Loop 替
Reporting Service for 
连接池 for php ---- sq
PostgreSQL 8.0 Beta 2 
tomcat中使用SQL Server
pager procedure for sq
更多内容
利用C#在SQL Server2000存取图像 For Window         
利用C#在SQL Server2000存取图像 For Window
作者:yufengly 文章来源:不详 点击数: 更新时间: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] 下一页

文章录入:mintao    责任编辑:mintao 
  • 上一篇文章:

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

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

    Copyright @ 2007 MinTao学以致用网(www.mintao.net) Inc All Rights Reserved.
    QQ:543098146有事请Q我! QQ:261561092有事请Q我 QQ:179647303有事请Q我 MSN:min906@126.com
    站长:MinTao 信息产业部ICP备案号:鄂ICP备07500065号

    学以致用是我们学习者的至高境界和不懈追求,[MinTao学以致用网]与大家共同学习,共同进步……
    信息产业部备案
    *鄂ICP备07500065号