类库:https://files.cnblogs.com/ankoe/Fish.DataAccessLib.rar提供了数据库的连接设置接口


  1using System;
  2using System.Drawing;
  3using System.Collections;
  4using System.ComponentModel;
  5using System.Windows.Forms;
  6using System.Data;
  7
  8using Fish.DataAccessLib;
  9namespace TestLib
 10{
 11    /// <summary>
 12    /// Form1 的摘要说明。
 13    /// </summary>

 14    public class Form1 : System.Windows.Forms.Form
 15    {
 16        private System.Windows.Forms.DataGrid dataGrid1;
 17        private ConnectionType ConnectionType1=new ConnectionType();
 18        /// <summary>
 19        /// 必需的设计器变量。
 20        /// </summary>

 21        private System.ComponentModel.Container components = null;
 22
 23        public Form1()
 24        {
 25            //
 26            // Windows 窗体设计器支持所必需的
 27            //
 28            InitializeComponent();
 29
 30            //
 31            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
 32            //
 33        }

 34
 35        /// <summary>
 36        /// 清理所有正在使用的资源。
 37        /// </summary>

 38        protected override void Dispose( bool disposing )
 39        {
 40            if( disposing )
 41            {
 42                if (components != null
 43                {
 44                    components.Dispose();
 45                }

 46            }

 47            base.Dispose( disposing );
 48        }

 49
 50        #region Windows 窗体设计器生成的代码
 51        /// <summary>
 52        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
 53        /// 此方法的内容。
 54        /// </summary>

 55        private void InitializeComponent()
 56        {
 57            this.dataGrid1 = new System.Windows.Forms.DataGrid();
 58            ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
 59            this.SuspendLayout();
 60            // 
 61            // dataGrid1
 62            // 
 63            this.dataGrid1.DataMember = "";
 64            this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
 65            this.dataGrid1.Location = new System.Drawing.Point(4816);
 66            this.dataGrid1.Name = "dataGrid1";
 67            this.dataGrid1.Size = new System.Drawing.Size(200178);
 68            this.dataGrid1.TabIndex = 0;
 69            // 
 70            // Form1
 71            // 
 72            this.AutoScaleBaseSize = new System.Drawing.Size(614);
 73            this.ClientSize = new System.Drawing.Size(292266);
 74            this.Controls.Add(this.dataGrid1);
 75            this.Name = "Form1";
 76            this.Text = "Form1";
 77            this.Load += new System.EventHandler(this.Form1_Load);
 78            ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
 79            this.ResumeLayout(false);
 80
 81        }

 82        #endregion

 83
 84        /// <summary>
 85        /// 应用程序的主入口点。
 86        /// </summary>

 87        [STAThread]
 88        static void Main() 
 89        {
 90            Application.Run(new Form1());
 91        }

 92
 93        private void Form1_Load(object sender, System.EventArgs e)
 94        {
 95            DataSet ds = SqlHelper.ExecuteDataset(ConnectionType1.SqlConnection,CommandType.Text,"select * from U_XtraColumnSet");
 96            DataView dv = ds.Tables[0].DefaultView;
 97            this.dataGrid1.DataSource = dv;
 98                    
 99        }

100    }

101}

102

SQL:
CREATE TABLE [U_XtraColumnSet] (
    
[AutoID] [int] IDENTITY (11NOT NULL ,
    
[cUser_ID] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
    
[cReport] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    
[bFieldKey] [bit] NULL ,
    
[iItemOrder] [int] NULL ,
    
[cFieldName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    
[cTitle] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    
[bSelected] [bit] NULL ,
    
[iWidth] [int] NULL ,
    
[bReadOnly] [bit] NULL ,
    
[cSummaryType] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    
[cGroupSummaryType] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    
[cSummaryDispFormat] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    
[cGroupSummaryDispFormat] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    
[cAlignment] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    
[cFormatString] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    
[cFormatType] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
ON [PRIMARY]
GO


posted on 2005-05-28 11:40  蚂蚁  阅读(507)  评论(1)    收藏  举报